Can't Use Sleep Command in If Else Statement

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
soulreaver
Posts: 2
Joined: 22 May 2018, 02:10

Can't Use Sleep Command in If Else Statement

22 May 2018, 02:16

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
Rohwedder
Posts: 7623
Joined: 04 Jun 2014, 08:33
Location: Germany

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

22 May 2018, 06:19

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

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: No registered users and 367 guests