Sign in to follow this  
Followers 0
TouchOdeath

Control Focus

3 posts in this topic

#1 ·  Posted (edited)

This is just a simple script to see if the control has focus or not. All you have to do is say:

if ControlGetFocus($handle) <> "" then 
;do this code
endif

Example Script:

Run("notepad.exe")
While ControlGetFocus("[CLASS:Notepad]") = ""
sleep(1)
WEnd
MsgBox(0,ControlGetFocus("[CLASS:Notepad]"),"")

In this example its kindof used in place of winwait. But its interesting just because I have never thought of ControlGetFocus like that. Because it returns the ClassNN and I thought to myself "well what good is that" and now it just occured to me. If ControlGetFocus returns "" then the control isnt there or isnt focused.

Edited by TouchOdeath

Share this post


Link to post
Share on other sites



You missed something:

sleep(1) should be sleep(10) or maybe sleep(0). I don't blame you since it is not documented, but I thought you may want to know that for the future. You can read more about that in THIS thread. :)

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

You missed something:

sleep(1) should be sleep(10) or maybe sleep(0). I don't blame you since it is not documented, but I thought you may want to know that for the future. You can read more about that in THIS thread. :)

I was aware of that. sleep(1) or sleep(0) will work itself out to be sleep(10) anyways. So the problem fixes itself, but ya thanks for pointing that out.

Edited by TouchOdeath

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0