What happened to the Messenger Plus! forums on msghelp.net?
Shoutbox » MsgHelp Archive » Messenger Plus! for Live Messenger » Scripting » Check whether control is focused

Check whether control is focused
Author: Message:
ryxdp
Senior Member
****


Posts: 804
Reputation: 16
29 / Male / Flag
Joined: Jun 2006
O.P. Check whether control is focused
I have an EditControl that, when the text changes, checks whether it's focused (there is a secondary EditControl that does exactly the same). I searched the forums and found the GetFocus function via SetFocus, but the function doesn't seem to have any parameters. What I need to do is something like:

code:
if(Interop.Call('user32','GetFocus',EdtBox.Handle)){
//do stuff
}

Is there some way to do this?
04-11-2010 09:12 AM
Profile PM Find Quote Report
Matti
Elite Member
*****

Avatar
Script Developer and Helper

Posts: 1646
Reputation: 39
32 / Male / Flag
Joined: Apr 2004
RE: Check whether control is focused
GetFocus() returns the handle of the currently focused control, so you need to compare that return value to the handle of the control you want to react upon.
js code:
// Get the handle of the focused control
var hFocused = Interop.Call('user32', 'GetFocus');
// Check if it's our edit control
if( hFocused === PlusWnd.GetControlHandle('MyEditControl') ) {
    // Do stuff
}
Or the short version:
js code:
// Check whether our edit control has focus
if( Interop.Call('user32', 'GetFocus') === PlusWnd.GetControlHandle('MyEditControl') ) {
    // Do stuff
}
Plus! Script Developer | Plus! Beta Tester | Creator of Countdown Live | Co-developer of Screenshot Sender 5

Found my post useful? Rate me!
04-11-2010 12:42 PM
Profile E-Mail PM Web Find Quote Report
ryxdp
Senior Member
****


Posts: 804
Reputation: 16
29 / Male / Flag
Joined: Jun 2006
O.P. RE: Check whether control is focused
Thanks a lot, it seems to be working perfectly now :P

I just wasn't sure if it'd return what I wanted, from what the MSDN article said it seemed like it included entire windows as well.
04-11-2010 11:59 PM
Profile PM Find Quote Report
« 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