Reputation: 394
I have a "find.png" (attached)
The pyautogui.locateOnScreen is returning None, even after 20 screenshots!!!!
Using interpreter (code attached)
Note: 1) the image having the line, "import pyautogui as auto", is "find.png"
2)I have "find.png" in the same directory, it is founded( checked with PIL- Image)
Upvotes: 1
Views: 15840
Reputation: 5414
Try this:
location = pyautogui.locateOnScreen('testing.png', confidence =.8)
Upvotes: 5
Reputation: 126
After struggling with this forever also, finally figured out that you either use command line or print screen button with the windows key to take the screenshot. Using the snipping tool does not work so try:
image = pyautogui.screenshot()
image.save('testing.png')
Go and crop testing.png as small as possible so that locateOnScreen works faster. Then go back to the terminal and type:
pyautogui.locateOnScreen('testing.png')
Upvotes: 11
Reputation: 763
None simply means that PyAutoGui was unable to find your image on the screen, do remember the window is active where find.png was sampled from. If this doesn't work out then I believe the resolutions(from when you took the sample and the monitor used by you) are different. Let us know if you face any problem.
Upvotes: 0