Code: Select all
import pyautogui
import pydirectinput
import time
import keyboard
def loop1():
while True:
image_files = ["Screenshot 2025-01-25 153403.png"]
for filename in image_files:
try:
center_x, center_y = pyautogui.size()
center_x = center_x // 2
center_y = center_y // 2
region = (center_x - 750, center_y - 600, 1500, 1200)
nametag = pyautogui.locateCenterOnScreen(filename, confidence=0.6, region=region)
if nametag:
print("found")
x, y = nametag
pydirectinput.moveRel(x, y, duration=0.1)
print("found file", filename, "in", nametag)
time.sleep(1)
continue
except pyautogui.ImageNotFoundException:
time.sleep(2)
print('not found')
continue
time.sleep(1)
while True:
if keyboard.is_pressed('`'):
loop1()