-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Incorrect screen size on Mac #33
Comments
Is this similar to issue #12 ? If so, this has been fixed and you should update pyautogui by running:
|
Hmmm…. I’m using python 2.7 and it’s on the bootcamp Windows 8.1 side of a retina macbook pro. I’m not sure how that’d work out...
|
Hey guys. I had a similar problem using this library on Windows 10 on a 4k display - In my case, I found it was related to DPI scaling not being accounted for. I solved the issue by adding the following to my script:
There may be a similar bit of functionality for MacOS. |
@starbadger You solved my issue, it works on Windows 10, thanks. |
@starbadger Thank you, solved my issue on Windows 7 as well! |
Just put the issue up on Pillow - ty for the fix @starbadger - worked a treat! |
Pyautogui uses screencaps to find the location of stuff on the screen. The problem on macs with a retina display is that the screen output have double the number of pixels, to take advantage of the system’s greater pixel density for a crisper image.Therefore, when you take a screenshot, you get an image containing double the number of pixels than the same image from a non-retina Mac. One work around is to change the yield of pyscreeze._locateAll_opencv and pyscreeze._locateAll_python (the pyautogui source code): pyscreeze._locateAll_opencv:
pyscreeze._locateAll_python:
|
@kasperschnack I tried that fix, and got...
|
@domluther try changing |
@kasperschnack Yes, it does! Thanks. Is there any particular reason why on one of them you've done the *0.5 inside the parentheses and the other outside?? |
@domluther that was a mistake - have fixed it now :) |
Hello ! |
Hello @jerb6. You can modify the module directly. If you're not sure where it is located you can find the location open the python repl in your terminal and run the following commands:
This should reveal the location of the .py file. Edit it, save it and you should be good to go :). If you use an IDE like pycharm, you should be able to find the file by cmd+clicking on the import in your script. |
oh ! okay thank you very much @kasperschnack !! But I have another problem.. Sorry for bothering you, I'm a complete beginner ! I says : failed to change read-only status for the following files : |
It's wierd that your python packages/modules are installed in your /library directory I think. Normally they'd be installed in your $HOME-dir. I expect you're using the python installation that ships default with Mac OS. I believe that is the reason for the files being read-only. If you install Python with homebrew(which I would recommend you do) you probably wouldn't have this problem, although you might have to reinstall your packages. You might be able to change it from the IDE though without doing any reinstalls |
@kasperschnack I actually changed all directories on "read and write" because all was on "read only" ! |
I changed the lines of source code like @kasperschnack suggested, but nothing different is happening. I tried changing 0.5 to different factors so see if it had any effect but I still have pyautogui.size returning half of my resolution 1280 x 800 (instead of 2560 x 1600). Maybe I changed the code incorrectly and did something wrong with the indentation (I'm new to programming) or it's the fact that I'm running OSX 10.14.1 Mojave. It's like none of the saved changes are applied. The changed code looks like this: and:Hopefully anyone can help me solve this issue! |
I have to admit it's been a long while since if looked at this issue - but isn't 1280 x 800 is what you want? Have you tried out moving the cursor around using the library to see if it behaves as you'd expect? |
The problem is that I want to program python to take partial screenshots, which I program according to the pixel coordinates of my screen. For example, when using photoshop to find a specific spot on a full screenshot, the most right bottom pixel has coordinates 2560 x 1600. However, when I put my cursor at the right bottom of my screen and locate the coordinates with pyautogui it returns a value of 1280 x 800. I could work my way around it by dividing all coordinates by 2 for pyautogui functions, but your solution seemed more convenient for me. Unfortunately though I can not get it right. |
Unfortunately the check |
i might be too late.. i just solve this issue using the code below. [problematic code]
[imporved code]
env |
Thanks so much, this worked for me! |
I have the same problem here that I cannot solve. I'm using a Macbook as well, and when I run this code, it screenshots the whole screen. How do I make it so it is only a part of the screen? I understand this is a retina problem. I also ran this code to a windows computer and it worked fine when I changed to fit the pixels of the windows. #Screenshot for Region pyautogui.screenshot(f"{region}_{tab}_SOM.png", region = (320,337,519,439)) |
Running into this on a MacBook now. How is this an open issue from 2015? 🤯 |
Hi!
So I have a MacBook Pro retina running windows 8.1 on bootcamp.
And the actual screen resolution is 2880 x 1800, but pyautogii.size() returns 1920 x 1080.
I can't seem to find documentation about how to set these values nor have I been able to guess them.
I believe it has to do with the retina scaling, but as of right now the pointer is constantly thrown off.
Any help would be greatly appreciated!
The text was updated successfully, but these errors were encountered: