question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

locateOnScreen not working on Big Sur

See original GitHub issue

After upgrading to macOS Big Sur, the function locateOnScreen is unable to find any image.

Steps to reproduce:

  • Make sure “myimage.png” is visible on screen
  • run this code pyautogui.locateOnScreen("myimage.png")

Expected result:

The position is returned by the function.

Actual result:

None is returned by the function.

Issue Analytics

  • State:open
  • Created 2 years ago
  • Comments:8

github_iconTop GitHub Comments

1reaction
rez1-infcommented, Nov 7, 2021

@cj81499 i agree… this workaround could easily be implemented as a fix… but PyAutoGUI uses PyScreeze by the same author to do most of the work… and nobody seems to be updating that anymore… I’ll try implementing the fix there and do a pull request sometime soon… let’s see if that’ll work…

Edit: actually this workaround can’t be a fix… (or shouldn’t be)… because then every time a user tries to locate something on screen, it would take a screen shot twice… once for the ratio and once to locate…

so a deeper dive into the source code is necessary… take screen shot just once and use it for both measuring pixel ratio and location…

If someone who already worked on this code was aware of this issue, could have easily implemented the fix…

0reactions
cj81499commented, Nov 7, 2021

@rez1-inf I think the point is that this is really something the library ought to handle for the user. Correcting for display scaling is not something that I want to spend any time thinking about as a developer trying to throw some GUI automation together. While the workaround you linked is useful, this is still a BIG usability issue imo. At the very least, it should be documented clearly that such a workaround is needed for displays with scaling.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Mac OS - Resolution problem / locateonscreen/get position #281
Hello, I have a problem with locate onscreen function. I try to let my python script find a specific picture in the screen...
Read more >
python - pyautogui code only working when debugging (with a ...
I want to make a program that automatically cleans my pc with CCleaner, by searching for specific images on the screen, moving the...
Read more >
Pyautogui LocateOnScreen not working in full screen - Reddit
I am searching for a cat walking in range of my standing character in a full screen game using pyautogui locateOnScreen(). The problem...
Read more >
Big Sur - Screenshots Not working - Apple Discussions
I've tried permissions, I've changed the OS (this problem started for me when KI upgraded to Catalina, and has followed me to Big...
Read more >
How to Fix Screenshot on Mac Not Working in 2023?
Why is my screenshot not working on Mac? ... data from macOS Monterey, macOS BigSur 11.0, macOS 10.15, macOS 10.14 (macOS Mojave) and...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found