I’m running linux (Pop OS 22.04) and I’m trying to make a loop using pyautgui.locateOnScreen method, here’s the code:
def __clicks_print(area, *print_names, clicks=1):
loc = None
while not loc:
for print_name in print_names:
loc = pyautogui.locateOnScreen(print_name, region=area)
print(loc)
if loc:
break
pyautogui.moveTo(loc)
pyautogui.click(clicks)
When I try to run the function the program ends-up stopping with the error below:
raise ImageNotFoundException # Raise PyAutoGUI's ImageNotFoundException.
The strange part is that I use this exact type of loop in Windows and it just works, the program keeps looking for a loc until it finds one.
I tried to copy the exact same function I have on a Windows machine and, it doesn’t work, the program keeps stopping when it fails to locate the pixels.
I want the program to keep looking until it finds the pixels on the screen. This way I can give the function multiple prints to locate.