0
votes
F1::pause,toggle



F2::
Loop,
{
PixelSearch, Px, Py, 432, 298, 444, 286, 0xFFEB63, 3, Fast

if (errorlevel = 0)
{
Sleep 5000
Click 1040,638
Sleep 1500
Click 1055,288
Sleep 10000
}
else{
sleep 3000
Click 1136, 642
sleep 10000

}

}

When I press F2 It should search for 0xFFEB63 in area.If color is not there then click 1136,642.At least,that was what I wanted to do.It directly jumps to else part.

1

1 Answers

0
votes

ErrorLevel is set to 0 if the color was found in the specified region, 1 if the color was not found, or 2 if there was a problem that prevented the command from conducting the search. https://autohotkey.com/docs/commands/PixelSearch.htm#ErrorLevel

F2::
Loop,
{
    PixelSearch, Px, Py, 432, 298, 444, 286, 0xFFEB63, 3, Fast
    if (errorlevel = 0)  ; If color is found in the first area
    {
        Sleep 5000
        Click 1040,638
        Sleep 1500
        Click 1055,288
        Sleep 10000
    }
    else
    if (errorlevel = 1)  ; If color is not in the first area
    {
        sleep 3000
        Click 1136, 642
        sleep 10000
    }
    ; else   ; if (errorlevel = 2) 
    ; do sth else
}
return

EDIT: You should use

CoordMode, Pixel, Screen

in the autoexecute-section, unless you want the Coordinates to be relative to the active window.