Reputation: 19
I have a very simple 'IfEqual' statement, that always goes to 'else'
I tried it with the 'If' statement, like 'If %GuiText1%=Var1' and 'If (GuiText1 = Var1)', but got the same result
Gui, Add, Button, x25 y8 cBlue vSA , Var1
Gui, Add, Button, x20 y8 cRed vSD , Var2
GuiControl, Hide, SD
Gui,Show
{
ControlGetText, GuiText1,, new.ahk //to get the button-text from the window
msgbox, %GuiText1% //to check if its the right variable
IfEqual, %GuiText1%, Var1
{
msgbox, 1
}
else
{
msgbox, 2
}
}
It always goes straigth to 'else'
Upvotes: 0
Views: 78
Reputation: 10543
Variable names in an expression are not enclosed in percent signs.
IfEqual, GuiText1, Var1
IfEqual is deprecated and not recommended for use in new scripts. Use the If Statement instead:
If GuiText1 = Var1 ; traditional mode
or, even better
If (GuiText1 = "Var1") ; expressional mode
Upvotes: 1