I've created a simple program that clicks black tiles in a piano.
from pyautogui import *
import pyautogui
import time
import keyboard
import random
import win32api, win32com
import image
#RGB (1,1,1)
#TILE 1 X = 353 Y = 380
#TILE 2 X = 404 Y = 380
#TILE 3 X = 455 Y = 380
#TILE 4 X = 511 Y = 380
def click(x,y):
win32api.SetCursorPos((x,y))
win32api.mouse_event(win32con.MOUSEEVENTF_LEFTDOWN,0,0)
time.sleep(0.01)
win32api.mouse_event(win32con.MOUSEEVENTF_LEFTUP,0,0)
while keyboard.is_pressed("q") == False:
if pyautogui.pixel(353, 380) [0] == 1:
click(353,380)
if pyautogui.pixel(404, 380) [0] == 1:
click(404,380)
if pyautogui.pixel(455, 380) [0] == 1:
click(455,380)
if pyautogui.pixel(511, 380) [0] == 1:
click(511,380)
raise WindowsError("windll.user32.ReleaseDC failed : return 0")
OSError: windll.user32.ReleaseDC failed : return 0
It gives this error, does anyone know why? I tried to search for it but nothing showed up.
EDIT (this is the error):
Python\Python39\lib\site-packages\pyscreeze\__init__.py", line 122, in __win32_openDC
raise WindowsError("windll.user32.ReleaseDC failed : return 0")
OSError: windll.user32.ReleaseDC failed : return 0