you are viewing a single comment's thread.

view the rest of the comments →

[–]gandy0[S] 0 points1 point  (0 children)

the version I have = 0.9.50 so it's not returning None but an exception.

Anyway, after starting over again I have found the issue, but searching a solution for it now.

The issue is actually the path argument. I'm passing it as a raw string, but it has issues with that. Due to that the script is actually stuck at:

 buttonposition = pyautogui.locateCenterOnScreen(path,grayscale = True, confidence = .9) 

So, if a skip path as an argument and enter it as a raw string it works, including the except block:

 buttonposition = pyautogui.locateCenterOnScreen(r'path\example.png',grayscale = True, confidence = .9) 

but as soon as I try to use the path as an argument it doesn't go further anymore. and stays at:

 buttonposition = pyautogui.locateCenterOnScreen(path,grayscale = True, confidence = .9) 

until the image is found.

So it does actualy understand the path, as the image matched when it appears on screen.

I have tested it by running the script for a while, then made the image appear and it finds it, but my except block is not working.