I've been having this problem while trying to make a piano tiles bot, the first time i used this function it for some reason returns this error, and idk why
import pyautogui
# R G B
black = (17, 17, 17)
# x, y
box1 = (757, 815)
box2 = (885, 817)
box3 = (1010, 816)
box4 = (1135, 822)
#start game
x, y = pyautogui.locateCenterOnScreen('Python\Python Programs\TESTING\start_black.png', region=(706, 550, 1194, 726))
pyautogui.click(x, y)
while True:
if pyautogui.pixelMatchesColor(*box1, black):
pyautogui.click(*box1)
elif pyautogui.pixelMatchesColor(*box2, black):
pyautogui.click(*box2)
elif pyautogui.pixelMatchesColor(*box3, black):
pyautogui.click(*box3)
elif pyautogui.pixelMatchesColor(*box4, black):
pyautogui.click(*box4)
Full Error:
Traceback (most recent call last):
File "e:/Utilities_and_Apps/Python/MY PROJECTS/Python/Python Programs/TESTING/tester.py", line 16, in <module>
if pyautogui.pixelMatchesColor(757, 815, black):
File "E:\Utilities_and_Apps\Python\lib\site-packages\pyscreeze\__init__.py", line 559, in pixelMatchesColor
pix = pixel(x, y)
return (r, g, b)
File "E:\Utilities_and_Apps\Python\lib\contextlib.py", line 120, in __exit__
next(self.gen)
File "E:\Utilities_and_Apps\Python\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