PhilHibbs Posted April 20, 2010 Share Posted April 20, 2010 (edited) When using Send() or ControlSend(), it isn't guaranteed that text will go to the right place if something interrupts the operation. Another window might steal focus, or focus might be moved by an accidental mouse click. Simple cases, where you just want to set an Edit control to a particular value, can be dealt with like this: const $ControlID = "[CLASS:Edit; INSTANCE:1]" const $Clear = "{HOME}+{END}{DEL}" While ControlGetText( $WindowText, "", $ControlID ) <> $ControlText And Not($Abort) ControlSend( $WindowText, "", $ControlID, $Clear & $ControlText ) WEnd You can extend this to multiple controls in two ways - individual While loops with a surrounding loop that checks them all, or just do away with the individual loops and have all the checks in one While and all the ControlSends inside the While. If you have a more complex requirement, such as inserting text into a RichEdit control, then that is much more tricky and I don't really have an answer to that, but the above technique has made my application launcher much more robust. The $Abort variable is a flag that I set in a HotKeySet() so that the user can interrupt an operation that is going haywire. $Abort=False HotKeySet("{Esc}","Abort") Func Abort() HotKeySet("{Esc}") $Abort = True EndFunc Edited April 20, 2010 by PhilHibbs Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now