2

I just followed some tutorial on piano tiles bot, but I've came across this error and I don't know what to do in order to solve it because Google lacks knowledge on this specific topic. I'm using Win10 x64 and Python 3.9

Here's my code:

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

#X:  486 Y:  800
#X:  611 Y:  800
#X:  732 Y:  800
#X:  835 Y:  800

def click(x,y):
    pyautogui.click(x,y)

while keyboard.is_pressed('q') == False:
    if pyautogui.pixel(486, 800)[0] == 0:
        click(486, 800)
    if pyautogui.pixel(611, 800)[0] == 0:
        click(611, 800)
    if pyautogui.pixel(732, 800)[0] == 0:
        click(732, 800)
    if pyautogui.pixel(835, 800)[0] == 0:
        click(835, 800)

and here's the error that I'm getting:

Traceback (most recent call last):
  File "D:\Py\Piano Tiles bot\pianotilesbot.py", line 24, in <module>
    if pyautogui.pixel(835, 800)[0] == 0:
  File "C:\Users\dog\AppData\Local\Programs\Python\Python39\lib\site-packages\pyscreeze\__init__.py", line 584, in pixel
    return (r, g, b)
  File "C:\Users\dog\AppData\Local\Programs\Python\Python39\lib\contextlib.py", line 124, in __exit__
    next(self.gen)
  File "C:\Users\dog\AppData\Local\Programs\Python\Python39\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
Tomerikoo
  • 18,379
  • 16
  • 47
  • 61
Dingus
  • 21
  • 3
  • 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