0

when i ran the code below i got this error:

File "e:\pranil\python\doing shit with python\automating dino game.py", line 12, in if auto.pixelMatchesColor(i,j, (83, 83, 83)): File "C:\Users\Pranil.DESKTOP-TLQKP4G.000\AppData\Local\Programs\Python\Python38\lib\site-packages\pyscreeze__init__.py", line 559, in pixelMatchesColor pix = pixel(x, y) File "C:\Users\Pranil.DESKTOP-TLQKP4G.000\AppData\Local\Programs\Python\Python38\lib\site-packages\pyscreeze__init__.py", line 584, in pixel return (r, g, b) File "C:\Users\Pranil.DESKTOP-TLQKP4G.000\AppData\Local\Programs\Python\Python38\lib\contextlib.py", line 120, in exit next(self.gen) File "C:\Users\Pranil.DESKTOP-TLQKP4G.000\AppData\Local\Programs\Python\Python38\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

import pyautogui as auto
from PIL import Image, ImageColor
import time
import keyboard
auto.FAILSAFE = False
time.sleep(2)
# print(auto.position())
while True:
    sshot = auto.screenshot()
    for j in range(510, 514):
        for i in range(316, 350):
            if auto.pixelMatchesColor(i,j, (83, 83, 83)):
                auto.press('up')
    if keyboard.is_pressed('q'):
        break
Paul R
  • 208,748
  • 37
  • 389
  • 560
  • It's a bug. See this answer: https://stackoverflow.com/a/67988905/495990 – Hendy Jun 15 '21 at 15:11
  • 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:42

1 Answers1

0

I'd suggest downgrading your python from 3.8 to 3.7, cause that solved it for me.