[Python] PyAutoGUI Script no longer working - "windll.gdi32.getpixel failed"

Discussão em 'Python' iniciado por Stack, Setembro 11, 2025.

  1. Stack

    Stack Membro Participativo

    My script has been working fine for the past month or so (up til yesterday), but as of today when I run it, it returns the following:

    Traceback (most recent call last):

    File "C:\...\main.py", line 39, in <module>
    pxFish = pyautogui.pixelMatchesColor(int(fishLocX), int(fishLocY), (76, 76, 76), tolerance=50)

    File "C:\Users\AppData\Local\Programs\Python\Python310\lib\site-packages\pyscreeze\__init__.py", line 589, in pixelMatchesColor
    pix = pixel(x, y)

    File "C:\Users\AppData\Local\Programs\Python\Python310\lib\site-packages\pyscreeze\__init__.py", line 610, in pixel
    raise WindowsError("windll.gdi32.GetPixel failed : return {}".format(color))

    OSError: windll.gdi32.GetPixel failed : return -1


    I haven't made any changes to the code or to my system, so I have no idea why it'd just suddenly stop working. Help would be appreciated.

    Also, somewhat bizarrely, my other functionally identical script still works (i.e. uses pixelMatchesColor, pyautogui click etc.).

    Cheers.

    Edit: It started working again out of nowhere. Didn't do anything at all. Epic. Very cool.

    Continue reading...

Compartilhe esta Página