import os import sys import time import easyocr import pyautogui from cv2_test import calc_boll_count reader = easyocr.Reader(['ch_sim','en'], gpu = True) # need to run only once to load model into memory tmp_path=os.getenv("TEMP") if not os.path.exists("scr_path"): os.mkdir("scr_path") def get_text(left:int,top:int,wid:int,hit:int)->list[str]: img = pyautogui.screenshot(region=[left, top, wid, hit]) img.save(f"{tmp_path}\\screenshot.png") result = reader.readtext(f"{tmp_path}\\screenshot.png") ret=[] for item in result: ret.append(item[1]) return ret def get_scr(left:int,top:int,wid:int,hit:int,text:str): img = pyautogui.screenshot(region=[left, top, wid, hit]) img.save(f"scr_path\\{time.strftime('%Y%m%d_%H%M%S')}_{text}.png") def get_boll_count(left:int,top:int,wid:int,hit:int): path=f"{tmp_path}\\boll_scr.png" img = pyautogui.screenshot(region=[left, top, wid, hit]) img.save(path) return calc_boll_count(path) def mouse_touch(left:int,top:int,wid:int,hit:int): x,y=pyautogui.position() if(x>left and xtop and y