Skip to content
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

pyautogui.size() on OS X Retina Macbook Pro #12

Closed
dsiah opened this issue Dec 27, 2014 · 5 comments
Closed

pyautogui.size() on OS X Retina Macbook Pro #12

dsiah opened this issue Dec 27, 2014 · 5 comments

Comments

@dsiah
Copy link

dsiah commented Dec 27, 2014

Hello,

I was going through basic usage of pyautogui and I found that the command

 pyautogui.size()

causes my python interpreter to freeze. I tried using it in a file and that also hung. Is this a problem with Retina, OS X, laptops, etc?

Note: the other commands seem to be working properly -- only size is giving me trouble

Thanks

@asweigart
Copy link
Owner

What's the version of OS X you have? (The specific version, like Mavericks 10.0.4 or such.)

@dsiah
Copy link
Author

dsiah commented Dec 27, 2014

Yosemite version 10.10.1

@jeremygray
Copy link
Contributor

Related, not sure if you'd like a separate issue for this: On Mac 10.9.5 with a retina display 1440 x 900, I get screenshot() sizes that are exactly twice as large as expected. This appears to carry through to the locate() family of functions, and return coordinates that are off by a factor of 2.

>>>> pyautogui.screenshot()
<PIL.PngImagePlugin.PngImageFile image mode=RGB size=2880x1800 at 0x106CFCF80>

@faurehu
Copy link

faurehu commented Mar 31, 2015

I ran a tracer to follow the interpretation of pyautogui and apparently it gets stuck here:
pyautogui/__init__.py:122 line return platformModule._size()

platformModule being pyautogui._pyautogui_osx I looked into it and the _size() method makes use of Quartz.CGDisplayPixelsWide(0). Tracing that function gave me this:

        Quartz/__init__.py:79    return            mod.QuickLookUI = m
                                 ...       return value: None
        Quartz/__init__.py:83    return    _load()
                                 ...       return value: None

Looking at the init file, m is supposed to be QuickLookUI, also in the Quartz folder. I can't tell why the return value is None.

@aaruff
Copy link
Contributor

aaruff commented May 4, 2015

I also experienced the same issue (MacBook Pro 10.10.3 (Retina, 13-inch, Late 2013)). Though I remedied the issue by replace 0 with Quartz.CGMainDisplayID() in the _size function. Further investigation is required to determine why exactly this issue arose in the first place.

def _size():
    return Quartz.CGDisplayPixelsWide(Quartz.CGMainDisplayID()), Quartz.CGDisplayPixelsHigh(Quartz.CGMainDisplayID())

asweigart added a commit that referenced this issue May 7, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants