If commands Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
ProItzAGamer
Posts: 2
Joined: 22 May 2018, 15:55

If commands

23 May 2018, 02:00

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
gregster
Posts: 8988
Joined: 30 Sep 2013, 06:48

Re: If commands  Topic is solved

23 May 2018, 02:16

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!

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
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)
ProItzAGamer
Posts: 2
Joined: 22 May 2018, 15:55

Re: If commands

23 May 2018, 11:43

This works. Thank you!

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Google [Bot], Rohwedder and 264 guests