Sep-26-2021, 07:07 AM
I'm running Python 3.8.10 on Lubuntu 20.04 LTS.
How can I modify:
so that it loops until
See, in my script, the following works approximately 90% of the time for me:
But about 10% of the time it fails resulting in:
Based on https://stackoverflow.com/questions/6814...-just-fine it seems like instead of running my code once, perhaps I should loop the following function until the image is detected. I don't know how to implement it, but once again based on https://stackoverflow.com/questions/6814...-just-fine the following seems like it would be helpful...
How can I modify:
a, b = pyautogui.locateCenterOnScreen('/home/image01.png', confidence=0.6, region=(25,500,1700,570))
so that it loops until
image01.png
is found?See, in my script, the following works approximately 90% of the time for me:
a, b = pyautogui.locateCenterOnScreen('/home/image01.png', confidence=0.6, region=(25,500,1700,570))
But about 10% of the time it fails resulting in:
TypeError: 'NoneType' object is not iterable
Based on https://stackoverflow.com/questions/6814...-just-fine it seems like instead of running my code once, perhaps I should loop the following function until the image is detected. I don't know how to implement it, but once again based on https://stackoverflow.com/questions/6814...-just-fine the following seems like it would be helpful...
def detect_image(path, duration=0): while True: image_location = pyautogui.locateCenterOnScreen(path) if image_location: pyautogui.click(image_location[0], image_location[1], duration=duration) break