I have a script, which is working more or less.
I started a program and pressed some keys.
Depending on several factors the program show one of two screens. If the screen is number 1 then it should only run to the end (title: 10-2013 2013.06.17. Screen x). If the screen is number 2 then it should press another key and then run to the end (title: 10-2013 2013.06.17. Screen y).
The screen titles are not simple titles but they depend on some input, so here is what I tried:
SetTitleMatchMode 2
; Wait for any of the two screens
WinWait,%5%-%1% - %2% - Screen
; If it is the second screen
MyTitle = %5%-%1% - %2% - Screen y
WinGetActiveTitle,title
If(title = MyTitle)
{
ControlSend,Static39,{Esc},%5%-%1% - %2% - Screen y
Sleep 2000
}
; Here are the common part again
ExitProgram:
The condition does not work. If I try it like above it does not go inside the condition. If I use %title% then it says "invalid characters in variable name 10-2013 2013.06.17. Screen y".
Solution
Based on Robert's answer
SetTitleMatchMode 2
WinWait,%5%-%1% - %2% - Screen
IfWinExist %5%-%1% - %2% - Screen y
{
ControlSend,Static39,{Esc},%5%-%1% - %2% - Screen y
Sleep 2000
}
IfEqual, var, value
orif(var = %value%)
. Consequentially, when comparing two string variables, one always has to be inside percent signs. – MCL