I am fairly new to AHK so this problem might be simple. My if commands arent working and im not sure why. Can anybody help?
InputBox, hiveNumber, Claimed Hive, What hive have you claimed?
if (%hiveNumber% = 1)
MsgBox, 1
else if (%hiveNumber% = 2)
MsgBox, 2
else if (%hiveNumber% = 3)
loop,
{Send {s down}
sleep, 2000
Send {s up}
Send {d down}
sleep, 7000
Send {d up}
Send {s down}
sleep, 3000
Send {s up}
sleep, 37500
Send {w down}
sleep, 3000
Send {w up}
Send {a down}
sleep, 7000
Send {a up}
Send {w down}
sleep, 2000
Send {w up}
Send {e 1}
sleep, 10000
}
else if (%hiveNumber% = 4)
MsgBox, 4
else if (%hiveNumber% = 5)
MsgBox, 5
else
MsgBox, Invalid Number
return
If commands Topic is solved
-
- Posts: 2
- Joined: 22 May 2018, 15:55
Re: If commands Topic is solved
It's good that you tried to use if-expression syntax, with the parentheses. But in an expression, don't use %s to get the contents of a variable!
If you do it like you did (still valid syntax), if will take the contents of the variable and look for another variable with a name that matches that original variable contents (there are use cases for that, too - but it is not the common case)
Code: Select all
InputBox, hiveNumber, Claimed Hive, What hive have you claimed?
if (hiveNumber = 1)
MsgBox, 1
else if (hiveNumber = 2)
MsgBox, 2
else
msgbox none
-
- Posts: 2
- Joined: 22 May 2018, 15:55
Re: If commands
This works. Thank you!
Who is online
Users browsing this forum: deets, imstupidpleshelp, Jaroz, mikeyww, OrangeCat and 139 guests