I used the Code Builder to insert "SetFocus>" in a script. I selected the RegEx option so it looked like this:
Let>WIN_REGEX=1
SetFocus>Skype
Alone in a script this works fine. However, in my script it did not focus consistently. Then I realized that I had used "Window Handles" earlier in the script:
Let>WIN_USEHANDLE=1
GetActiveWindow>tmp,nXPos,nYPos,,
If I understand it correctly then both the RegEx and the Window Handles options were active at the same time(conflict??). So then I added a line before "SetFocus" where I turn off the "Window Handles" and then it seems to work fine.
Let>WIN_USEHANDLE=0
Let>WIN_REGEX=1
SetFocus>Skype
Is my understanding correct that when you eg use Code Builder and change "mode" you may have to turn off any old ones "manually" to avoid conflicts?
SetFocus
Moderators: JRL, Dorian (MJT support)
Re: SetFocus
Did some more thinking and I think it is clear to me now.
The systems variables start off at default values and stay unchanged until changed (or end), ie in my case "using Window Handles" is active also later in the program. By using "SetFocus" with RegEx selected it was actually trying to match a Window Handle, ie a number and not the title, therefore no match. By turning "using Window Handles" off it matched the window title instead and everything was fine.
Conclusion, one needs to be careful when changing systems variables as there could be impacts in other (easy to forget) places.
The systems variables start off at default values and stay unchanged until changed (or end), ie in my case "using Window Handles" is active also later in the program. By using "SetFocus" with RegEx selected it was actually trying to match a Window Handle, ie a number and not the title, therefore no match. By turning "using Window Handles" off it matched the window title instead and everything was fine.
Conclusion, one needs to be careful when changing systems variables as there could be impacts in other (easy to forget) places.