I'm trying to automate a simple thing. A popup pops up, my script finds it and clicks on the button I took a screenshot of (erteilen.png). Half a second later the same popup pops up again, but my script won't notice it.
This is my code:
import pyautogui as pg
while True:
window = pg.locateOnScreen("erteilen.png", minSearchTime=3, confidence=0.9)
try:
print(window)
pg.click(x=window.left+int(window.width/2), y=window.top+int(window.height/2), clicks=3)
except Exception as e:
print("Error:", e)
break
It will click on the found window, then the same window opens again, but the script won't locate it again. When I click in the command window, it seems like pyautogui refreshes it's screen and then finds the window.
How can I tell PyAutoGUI to 'refresh' what it sees itself, so that it gets updated informations and finds the new windows as well?
Thanks in advance!
Michael
from PyAutoGUI - result will only get parsed once
No comments:
Post a Comment