Oct-05-2021, 12:47 PM
Essentially I want my Python script to perform this...
In other words, how can I have my script check to see if PyautoGUI has successfully located the center of
See, about 95% of the time the following works correctly....
x = True if x == True: print('Congratulations, you won!') else: print('I'm sorry but you lost.')with this...
a, b = pyautogui.locateCenterOnScreen('~/home/file_01.png', region=(1065,250,385,700), confidence=0.9)
In other words, how can I have my script check to see if PyautoGUI has successfully located the center of
~/home/file_01.png
?See, about 95% of the time the following works correctly....
a, b = pyautogui.locateCenterOnScreen('~/home/file_01.png', region=(1065,250,385,700), confidence=0.9)But about 5% of the time
~/home/file_01.png
does not exist. In those cases my script stops and throws off the following error message...TypeError: cannot unpack non-iterable NoneType objectInstead of having my script stops in cases when
~/home/file_01.png
does not exist I would prefer that my script skip that instance. In other words, instead of stopping I want my script to ignore cases when ~/home/file_01.png
does not exist.