Page 1 of 1

Can't Use Sleep Command in If Else Statement

Posted: 22 May 2018, 02:16
by soulreaver
Hi there,

So I am trying to make a script that checks to see if one pixel is a certain color, then if it is, presses a button. If not, it moves onto the next statement: if another pixel is a certain color, then I want it to press a button and wait 400 milliseconds. Else, then just press another button. The problem is, whenever I try to put in the sleep command, I get an error saying the last else statement has no if part to it. This is what I have so far:

Code: Select all

CoordMode, pixel,screen
e::
PixelGetColor, color1, 733, 1059
PixelGetColor, color2, 216, 101
    If color1=0x080909
        Send {F4}
    else if color2=0xF9C1F4
        Send {F5}
        sleep, 400
    else
        Send {F6}
sleep 1000
return

Re: Can't Use Sleep Command in If Else Statement

Posted: 22 May 2018, 06:19
by Rohwedder
Hallo,
try:

Code: Select all

CoordMode, pixel,screen
e::
PixelGetColor, color1, 733, 1059
PixelGetColor, color2, 216, 101
    If color1=0x080909
        Send {F4}
    else if color2=0xF9C1F4
	{
        Send {F5}
        sleep, 400
	}
    else
        Send {F6}
sleep 1000
return
https://autohotkey.com/docs/commands/Block.htm