Jump to content

Recommended Posts

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
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

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
×
×
  • Create New...