Untitled
unknown
plain_text
6 months ago
1.8 kB
4
Indexable
import time import numpy as np from mss import mss import pyautogui as pg import threading import random time.sleep(8) #время чтобы открыть кладку с блюмом monitor = { "left": pg.position().x, # Координата x приложения блум "top": pg.position().y, # Координата y приложения блум "width": 385, "height": 650, } # Искомый цвет our_color = [205, 220, 0] click_x = monitor.get('left') + 170 # Координата X кнопки Play click_y = monitor.get('top') + 625 # Координата Y кнопки Play # Поиск цвета на экране def find_color(our_color, monitor={}): # Возьмем кусок экрана with mss() as m: img = m.grab(monitor) img_arr = np.array(img) # Преобразуем этот кусок в матрицу our_map = (our_color[2], our_color[1], our_color[0], 255) indexes = np.where(np.all(img_arr == our_map, axis=-1)) our_crd = np.transpose(indexes) return our_crd def click_periodically(x, y): while True: pg.click(x, y) interval = random.randint(35, 45) time.sleep(interval) click_thread = threading.Thread(target=click_periodically, args=(click_x, click_y)) click_thread.daemon = True # Делает поток фоновым, чтобы он завершался при завершении основного потока click_thread.start() while True: result = find_color(our_color, monitor) if result.size > 0: x = result[0][1] + monitor.get('left') y = result[0][0] + monitor.get('top') pg.click(x, y)
Editor is loading...
Leave a Comment