autoit.pixel_search returning color is not found
Question: I'm trying to grab the coordinates for a specific pixel value on the screen,
but I can't seem to get any results. The error I get is
"autoit.autoit.AutoItError: color is not found".

To verify my code I have the mouse move the the pixel that has the colour I
want. This is not necessary, it was just part of a test. I have two monitors
and my fear was that the pixel search couldn't distinguish what monitor I
wanted. So to test autoit knew where to look I did a basic "move mouse". Sure
enough it moved to my image on monitor one, so I know it has the right
monitor.

Second I tested if the "autoit.pixel_get_color" could grab the value I wanted,
it does (65281).Thought I might have to use the decimal instead of the HEX
provided from the Windows Info application.

I tested with the code below, this is the code using SciTE - light (.au3 file)
and it works fine.

    
    
    $coord = PixelSearch(0, 0, 1434, 899, 0x00FF02)
    
    If Not @error Then
        MsgBox(0, "X and Y are:", $coord[0] & "," & $coord[1])
    EndIf
    

I tested grabbing the pixel with pyautogui and ultimately I can do it, but it
is not as "clean" as autoit, so I'm trying to avoid it if possible. Autoit has
that nice Window info screen that shows me the color, so it is really easy to
just plug numbers into my script.

Here is the code I have written currently in Python.

    
    
    import autoit
    
    import pyautogui
    
    pyautogui.confirm('Press OK to start running script')
    
    autoit.mouse_move(374,608,10) # move mouse to where the color I want is located.
    
    pixelcolor = autoit.pixel_get_color(374,608) #get color of pixel
    
    pixelsearch = autoit.pixel_search(0,0,1434,899,0x00FF02) # search entire screen for color
    
    pixelsearch = autoit.pixel_search(0,0,1434,899,65281) # Tried using the value from the get_color, still same error.
    

Any Ideas?


Answer: So I figured out how to resolve my problem. I don't know why it works or what
caused the problem, but for now here is the solution

The correct formula for PixelSearch is PixelSearch(left, top, right, bottom).

After playing around with the numbers it appears pyautoit is using (right,
top, left, bottom). If I plug in my numbers with that formula it works
perfectly, EXCEPT on my third monitor.

My third monitor seems to work with (left, top, right, bottom). I am wondering
if it has something to do with negative numbers (-1680, 0, -3, 1050), not 100%
sure.

I tested this on my work computer (two monitors), home computer, (three
monitors), and my laptop. In all scenarios the (right, top, left, bottom)
worked, except home computer on the third monitor.

Hope this helps someone else out in the future.

