What happened to the Messenger Plus! forums on msghelp.net?
Shoutbox » MsgHelp Archive » Messenger Plus! for Live Messenger » Scripting » [?] Detect x64 through JScript & EM_SETSEL on x64

Pages: (2): « First [ 1 ] 2 » Last »
[?] Detect x64 through JScript & EM_SETSEL on x64
Author: Message:
SmokingCookie
Senior Member
****

Avatar

Posts: 815
Reputation: 15
30 / Male / Flag
Joined: Jul 2007
O.P. [?] Detect x64 through JScript & EM_SETSEL on x64
Is it possible to detect whether MPL is running on a 64-bit version of Windows? I've tried conditional compilation, but @if(@_win32) seems to always return true, even on my x64 machine.

Second problem: EM_SETSEL does not set the selection to the specified start and stop indexes, but deselects all text. This seems to be an x64 problem (which is why I posted in the first place :P ). How can I solve this?

This post was edited on 01-31-2010 at 07:14 PM by SmokingCookie.
01-31-2010 07:11 PM
Profile PM Find Quote Report
Mnjul
forum super mod
******

Avatar
plz wub me

Posts: 5396
Reputation: 58
– / Other / Flag
Joined: Nov 2002
Status: Away
RE: [?] Detect x64 through JScript & EM_SETSEL on x64
Try IsWow64Process although I really don't think the EM_SETSEL thing has much to do with x64 :p
01-31-2010 07:30 PM
Profile PM Web Find Quote Report
SmokingCookie
Senior Member
****

Avatar

Posts: 815
Reputation: 15
30 / Male / Flag
Joined: Jul 2007
O.P. RE: [?] Detect x64 through JScript & EM_SETSEL on x64
I'll try have the IsWow64Process thingy.

About EM_SETSEL: I concluded it is an x64 problem after reading this: http://support.microsoft.com/kb/109550.

This post was edited on 01-31-2010 at 07:41 PM by SmokingCookie.
01-31-2010 07:35 PM
Profile PM Find Quote Report
TheBlasphemer
Senior Member
****

Avatar

Posts: 714
Reputation: 47
37 / – / –
Joined: Mar 2004
RE: [?] Detect x64 through JScript & EM_SETSEL on x64
It's far more likely that it's a bug in how you use it than it being related to x64.
Messenger is a x86 (32-bit) program, and as such is run in a x86 enviroment with x86 APIs. x86 processes do not have access to x64 APIs, and as such EM_SETSEL would just take 32-bit parameters.
The article you mentioned is about 16-bit vs 32-bit, not about 32-bit to 64-bit, and on top of that it checks on-compile time, meaning that if you'd compile your app as 16-bit, it'd have used the 16-bit methods. Messenger is compiled as 32-bit, and as such should just use 32-bit APIs.
Furthermore, changing your programs behaviour on x64 windows even though you're a x86 process would only introduce weird bugs.

I'd suggest you read up on EM_SETSEL here and try to find out where you went wrong.
Also I suggest you test your script on a 32-bit machine, and I can almost assure you that the same bug will appear, as it's most definitely not related to your 64-bit OS ;)
[Image: theblasp.png]
02-02-2010 12:03 PM
Profile PM Find Quote Report
SmokingCookie
Senior Member
****

Avatar

Posts: 815
Reputation: 15
30 / Male / Flag
Joined: Jul 2007
O.P. RE: [?] Detect x64 through JScript & EM_SETSEL on x64
:wall: Gotta get some reading lessons :S

Anyways, I started at the MSDN article. I guess I'd post some code?

JScript code:
// Example
var Text = "Hello world!";
var pText = "Hello world";

var SetSel = function(Start,End) {
    Interop.Call("User32.dll","SendMessageW",hWnd,EM_SETSEL,Start,End);
}

(...)

SetSel(Text.length,pText.length);

NB: the hWnd parameter is known.

This post was edited on 02-02-2010 at 07:42 PM by SmokingCookie.
02-02-2010 07:39 PM
Profile PM Find Quote Report
matty
Scripting Guru
*****


Posts: 8336
Reputation: 109
39 / Male / Flag
Joined: Dec 2002
Status: Away
RE: [?] Detect x64 through JScript & EM_SETSEL on x64
Just out of curiosity, I would have to test this myself but:
js code:
SetSel(12, 11)
Is essentially what you are doing... I dont know what the ramifications of that are or how long the text in the edit control you are testing is.

This post was edited on 02-02-2010 at 08:35 PM by matty.
02-02-2010 08:35 PM
Profile E-Mail PM Find Quote Report
SmokingCookie
Senior Member
****

Avatar

Posts: 815
Reputation: 15
30 / Male / Flag
Joined: Jul 2007
O.P. RE: [?] Detect x64 through JScript & EM_SETSEL on x64
Well, I've put a longer string in the edit box and tried indexes 4 and 12 (and reversed), but it still doesn't work: no text is selected. The edit control is basically a combo box with the AllowEdit attribute set to true.

Btw, what does "ramifications" mean? :P

This post was edited on 02-02-2010 at 08:44 PM by SmokingCookie.
02-02-2010 08:40 PM
Profile PM Find Quote Report
matty
Scripting Guru
*****


Posts: 8336
Reputation: 109
39 / Male / Flag
Joined: Dec 2002
Status: Away
RE: [?] Detect x64 through JScript & EM_SETSEL on x64
Ramifications: what sideeffects or what would happen by doing it.

Have you tried EM_GETSEL to see where the starting position is?

Stupid question but what do you have EM_SETSEL defined as? should be 0xB1

Is it an Edit or Rich Edit control? You cannot use that message for a control other than an edit or rich edit control.

quote:
Originally posted by http://msdn.microsoft.com/en-us/library/bb761661%28VS.85%29.aspx
EM_SETSEL

Selects a range of characters in an edit control. You can send this message to either an edit control or a rich edit control.

Look at the CB_SETEDITSEL message instead

wParam isn't used in this message. You will need to make a word consisting of the low and high bytes.

js code:
var makeword = function (a,b) { return a | (b << 8); }
Where A is the LowByte and B is the HighByte.

This post was edited on 02-02-2010 at 08:57 PM by matty.
02-02-2010 08:46 PM
Profile E-Mail PM Find Quote Report
SmokingCookie
Senior Member
****

Avatar

Posts: 815
Reputation: 15
30 / Male / Flag
Joined: Jul 2007
O.P. RE: [?] Detect x64 through JScript & EM_SETSEL on x64
Well, I've double-checked the EM_SETSEL, it is properly defined. I've just tried EM_GETSEL, starting and ending positions are both 0.

And thanks for adding a new word to my vocab :P

Seen your bump, reading now

Seen :p


I've been messing around with those macros, but can barely read them, due to all those casts :S :P Thanks for making it clear now ;)

Well you got me at least one step further: now all text is selected, and I know why:

JScript code:
Number.prototype.LOWORD = function() {
    return this & 0xFFFF;
}

Number.prototype.HIWORD = function() {
    return (this >> 16) & 0xFFFF;
}

var MAKEWORD = function (a,b) {
    return a | (b << 8);
}

var D = MAKEWORD(4,12);
Debug.Trace((4).toString(2));
Debug.Trace((12).toString(2));
Debug.Trace(D.toString(2));

Debug.Trace(D.LOWORD());
Debug.Trace(D.HIWORD());

Output:

quote:
100
1100
110000000100
3076
0

This post was edited on 02-02-2010 at 09:08 PM by SmokingCookie.
02-02-2010 08:53 PM
Profile PM Find Quote Report
TheBlasphemer
Senior Member
****

Avatar

Posts: 714
Reputation: 47
37 / – / –
Joined: Mar 2004
RE: [?] Detect x64 through JScript & EM_SETSEL on x64
quote:
Originally posted by SmokingCookie
Well, I've double-checked the EM_SETSEL, it is properly defined. I've just tried EM_GETSEL, starting and ending positions are both 0.

And thanks for adding a new word to my vocab :P

Seen your bump, reading now

Seen :p


I've been messing around with those macros, but can barely read them, due to all those casts :S :P Thanks for making it clear now ;)

Well you got me at least one step further: now all text is selected, and I know why:

JScript code:
Number.prototype.LOWORD = function() {
    return this & 0xFFFF;
}

Number.prototype.HIWORD = function() {
    return (this >> 16) & 0xFFFF;
}

var MAKEWORD = function (a,b) {
    return a | (b << 8);
}

var D = MAKEWORD(4,12);
Debug.Trace((4).toString(2));
Debug.Trace((12).toString(2));
Debug.Trace(D.toString(2));

Debug.Trace(D.LOWORD());
Debug.Trace(D.HIWORD());

Output:

Are you perhaps confusing MAKEWORD with MAKELONG ?
BYTE = 8-bit
WORD = 16-bit
DWORD/long = 32-bit

MAKEWORD takes two BYTEs and turns it into a WORD
MAKELONG takes two WORDs and turns it into a DWORD/LONG
LOWORD gets a WORD from a DWORD/LONG (first one passed to MAKELONG)
HIWORD " " " second one

I think in your code you intended to use MAKELONG instead of MAKEWORD, MAKELONG would be:
var MAKELONG = function(a,b) { return a|(b<<16); };
[Image: theblasp.png]
02-02-2010 10:15 PM
Profile PM Find Quote Report
Pages: (2): « First [ 1 ] 2 » Last »
« Next Oldest Return to Top Next Newest »


Threaded Mode | Linear Mode
View a Printable Version
Send this Thread to a Friend
Subscribe | Add to Favorites
Rate This Thread:

Forum Jump:

Forum Rules:
You cannot post new threads
You cannot post replies
You cannot post attachments
You can edit your posts
HTML is Off
myCode is On
Smilies are On
[img] Code is On