1
from pyautogui import *
import pyautogui
import time
import keyboard
import win32api, win32con

#Tile 1 X:  750 Y:  650 
#Tile 2 X:  890 Y:  650 
#Tile 3 X: 1020 Y:  650
#Tile 4 X: 1164 Y:  650

def click(x1,y1):
    pyautogui.click(x = x,y = y)
    pyautogui.PAUSE = 0

while keyboard.is_pressed('q') == False:

    if pyautogui.pixel(750, 650)[0] == 0:
        click(750, 650)
    if pyautogui.pixel(890, 650)[0] == 0:
        click(890, 650)
    if pyautogui.pixel(1020, 650)[0] == 0:
        click(1020, 650)
    if pyautogui.pixel(1164, 650)[0] == 0:
        click(1164, 650)

and i get this error

Traceback (most recent call last):
  File "E:\Desktop\Bot\Bot.py", line 18, in <module>
    if pyautogui.pixel(750, 650)[0] == 0:
  File "C:\Python 3.8.5\lib\site-packages\pyscreeze\__init__.py", line 584, in pixel
    return (r, g, b)
  File "C:\Python 3.8.5\lib\contextlib.py", line 120, in __exit__
    next(self.gen)
  File "C:\Python 3.8.5\lib\site-packages\pyscreeze\__init__.py", line 113, in __win32_openDC
    raise WindowsError("windll.user32.ReleaseDC failed : return 0")
OSError: windll.user32.ReleaseDC failed : return 0
Charles Duffy
  • 280,126
  • 43
  • 390
  • 441
DonutzROP
  • 11
  • 2
  • I would suggest filing this as a bug report to the [`pyscreeze`](https://pypi.org/project/PyScreeze/) project. – Charles Duffy Nov 08 '20 at 18:05
  • i dont know what pyscreeze is but ill look into it saw someone having the same problem when you edited the actual error and he fixed it by downgrading to python 3.7 instead of 3.8 so ill try that first – DonutzROP Nov 08 '20 at 18:12
  • If the upstream project has a compatibility issue with Python 3.8, that's a particularly worthwhile thing to make sure they have a bug report for, so they can try to fix it going forward. – Charles Duffy Nov 08 '20 at 18:13
  • ("pyscreeze" takes screenshots from Python; the `pixel` call from pyautogui is just a reference to a pyscreeze function of the same name and for the same purpose). – Charles Duffy Nov 08 '20 at 18:13
  • This is now [fixed](https://github.com/asweigart/pyautogui/issues/579) in `pyscreeze-1.0.28` (which `pyautogui` uses and where the bug was). – Hendy Sep 14 '21 at 14:43

0 Answers0