如何修复 'If statement' 总是 'else'

How to fix 'If statement' always going for 'else'

我有一个非常简单的 'IfEqual' 语句,它总是转到 'else'

我用 'If' 语句尝试过,例如 'If %GuiText1%=Var1' 和 'If (GuiText1 = Var1)',但得到了相同的结果

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

它总是直奔'else'

expression 中的变量名称未包含在百分号中。

IfEqual, GuiText1, Var1  

IfEqual 已弃用,不建议在新脚本中使用。 使用 If Statement 代替:

If GuiText1 = Var1   ; traditional mode

或者,甚至更好

If (GuiText1 = "Var1")   ; expressional mode