I’m trying to get this code to find the image on screen (1920×1080) but do nothing until it loses sight of the image then runs a basic print saying “No Image”
Code:
import time
import keyboard
import pyautogui
import win32api
import win32con
import schedule
def click():
win32api.mouse_event(win32con.MOUSEEVENTF_LEFTDOWN, 0, 0)
win32api.mouse_event(win32con.MOUSEEVENTF_LEFTUP, 0, 0)
time.sleep(0.1)
while not keyboard.is_pressed('q'):
start = pyautogui.locateCenterOnScreen('7.png', region=(0, 0, 1920, 1080), grayscale=True, confidence=0.70)
if start is not None:
pyautogui.moveTo(start) # Moves the mouse to the coordinates of the image
click()
else:
print("No image")
schedule.every(1).seconds.do(click)
while True:
schedule.run_pending()
time.sleep(1)