Untitled
unknown
plain_text
10 days ago
1.1 kB
8
Indexable
Never
import pyautogui as pg import threading import keyboard COLOR_POSITION = { 'green': {'position': (1064, 1265), 'color': (0, 152, 0), 'key': 'a'}, 'red': {'position': (1176, 1265), 'color': (255, 0, 0), 'key': 's'}, 'yellow': {'position': (1289, 1265), 'color': (244, 244, 2), 'key': 'j'}, 'blue': {'position': (1401, 1265), 'color': (0, 152, 255), 'key': 'k'}, 'orange': {'position': (1462, 1268), 'color': (255, 101, 0), 'key': 'l'}, } def check_color(info_color): while True: if pg.pixelMatchesColor(info_color['position'][0], info_color['position'][1], info_color['color']): pg.press(info_color['key']) def listen_for_exit(): keyboard.wait('1') exit() threads = [] for color, info in COLOR_POSITION.items(): thread = threading.Thread(target=check_color, args=(info,)) thread.daemon = True thread.start() threads.append(thread) exit_thread = threading.Thread(target=listen_for_exit) exit_thread.daemon = True exit_thread.start() exit_thread.join()
Leave a Comment