I would like to write a program about the image may popup any time, and the action is to close the image, not to click the image. I have some idea about the code, but not successful: (image NOT popup, but still wait for 1 sec and to click top right conner ..)
import pyautogui, time
while ture: pyautogui.click(pyautogui.center(pyautogui.locateOnScreen(r'C:\Users\Lawrence\Desktop\PyTest\image.png')))
time.sleep(1) #I want to check image every sec
break
pyautogui.click(1880,15) # after checking the screen for every sec, the image popup, and click top right conner to close it, finish
Try this. You are breaking too early and clicking the wrong stuff.
import pyautogui, time
while True:
#I want to check image every sec
time.sleep(.1) #put time interval for checking here
if pyautogui.locateOnScreen(r'C:\Users\Lawrence\Desktop\PyTest\image.png'):
pyautogui.click(1880,15)
break