Oct-05-2021, 12:47 PM
Essentially I want my Python script to perform this...
with 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....
But about 5% of the time
Instead of having my script stops in cases when
1 2 3 4 5 |
x = True if x = = True : print ( 'Congratulations, you won!' ) else : print ( 'I' m sorry but you lost.') |
1 |
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....
1 |
a, b = pyautogui.locateCenterOnScreen( '~/home/file_01.png' , region = ( 1065 , 250 , 385 , 700 ), confidence = 0.9 ) |
~/home/file_01.png
does not exist. In those cases my script stops and throws off the following error message...1 |
TypeError: cannot unpack non - iterable NoneType object |
~/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.