import cv2 import time import pyautogui from datetime import datetime, date eol = int(0) def find(image, coef=None): template = cv2.imread("assets/{}".format(image), 0) width, height = template.shape[::-1] screen = cv2.imread("screenshot.png", 0) width2, height2 = screen.shape[::-1] match = cv2.matchTemplate(screen, template, cv2.TM_CCOEFF_NORMED) value, location = cv2.minMaxLoc(match)[1], cv2.minMaxLoc(match)[3] if image == "assistduel.png": print(f"Val: {value} | {image}") if (value >= 0.8): print(f"Val: {value} | {image}") return (location[0], location[1], width, height, value) else: return None def autoduelloop(eol): while True: time.sleep(1) pyautogui.screenshot("screenshot.png") # OK Button okbutton = find("ok.png") if okbutton != None: pyautogui.click((okbutton[0], okbutton[1])) break # Next nextbutton = find("next.png") if nextbutton != None: pyautogui.click((nextbutton[0], nextbutton[1])) break # Rescue Complete rescom = find("mark.png") if rescom != None: pyautogui.click((rescom[0], rescom[1])) break # Level Up levelup = find("lvlup.png") if levelup != None: pyautogui.click((levelup[0], levelup[1])) break # Dialog dialog = find("rndclick.png") if dialog != None: pyautogui.click((dialog[0], dialog[1])) break # Auto-Duel autoduel = find("autoduel.png") if autoduel != None: pyautogui.click((autoduel[0], autoduel[1])) break # Close close = find("close.png") if close != None: pyautogui.click((close[0], close[1])) break # Assist Duel assist = find("assistduel.png") if assist != None: pyautogui.click((assist[0], assist[1])) break trsbox = find("trsbox.png") if trsbox != None: pyautogui.scroll(-4000, pause=1) pyautogui.scroll(-4000, pause=1) time.sleep(1) pyautogui.screenshot("screenshot.png") assist = find("assistduel.png") if assist != None: pyautogui.click((assist[0], assist[1])) break # Active Duel duellog = find("duellog.png") if duellog != None: time.sleep(5) break # Reboot reboot = find("reboot.png") if reboot != None: pyautogui.click((reboot[0], reboot[1])) break # Initiate Link initiate = find("Initiatelink.png") if initiate != None: pyautogui.click((initiate[0], initiate[1])) break # Main Menu mainmenu = find("mainmenu.png") if mainmenu != None: pyautogui.click((950, 280)) break # End of the Loop print(f"End of the Loop | EOL: {eol}") time.sleep(3) if eol >= 5: # Arrow arrow = find("arrow.png") if arrow != None: pyautogui.click((arrow[0], arrow[1])) break break while True: autoduelloop(eol) eol += 1 if eol == 10: pyautogui.click((950, 280)) elif eol >= 15: time.sleep(1) eol = int(0) pyautogui.screenshot(f"error/error-{datetime.now().strftime('%Y-%m-%d-%H-%M')}.png")