import time import pyautogui time.sleep(4) attackbutton = (1361, 300) y = 268 for x in (299, 564, 829, 1094, 1359, 1624): # found a pirate : pirate = pyautogui.locateCenterOnScreen('pirates.png', region=(0, 0, 1920, 1080), grayscale=True, confidence=0.70) if pirate is not None : pyautogui.moveTo(pirate) # move the mouse to the coords of the pirate time.sleep(1) #break 1 second pyautogui.click(pirate[0], pirate[1]) #click the pirate time.sleep(1) #click on attack button : pyautogui.click(attackbutton[0] , attackbutton[1]) time.sleep(1) #click fleet pyautogui.click(x, y) time.sleep(3)