Search code examples
autohotkeyerrorlevel

AutoHotKey PixelSearch and && (AND)


I need to write script like this:

if (PixelSearch && (other)PixelSearch == true)
{
// code
}

So I need to use Errorlevel, but how use Errorlevel with 2 different PixelSearch? Please help!


Solution

  • I haven't worked with AutoIt code lately, but I would solve it like this:

    ;Find a pure red pixel in the range 0,0-20,300
    $pixelSearchErrorOne = PixelSearch( 0, 0, 20, 300, 0xFF0000 );
    
    ; Find a pure red pixel or a red pixel within 10 shades variations of pure red
    $pixelSearchErrorTwo = PixelSearch( 0, 0, 20, 300, 0xFF0000, 10 );
    
    if (Ubound($pixelSearchErrorOne) < 2 || Ubound($pixelSearchErrorOne) < 2)
    {
    // code
    }
    

    The 'Ubound' returns the count of an array, and when a PixelSearch succeeded, the variable should be filled with a 2-dimensional array with the coords :)

    For more info on that, check: http://www.autoitscript.com/autoit3/docs/functions/PixelSearch.htm

    I'm not sure if the double pipeline (||) is the OR statement in autoIt, but you can look that up.