asweigart / pyautogui

A cross-platform GUI automation Python module for human beings. Used to programmatically control the mouse & keyboard.
BSD 3-Clause "New" or "Revised" License
10.5k stars 1.27k forks source link

macOS screen size not finding correct size #808

Open maddox05 opened 1 year ago

maddox05 commented 1 year ago

When calling pyautogui.size for Mac's with the Retina display, it says the wrong size,around half of what the size is. This causes locate on screen and mouse move to break.

jtranquilli commented 1 year ago

Could you provide your Mac's actual screens size along with what PyAutoGUI claims it to be? There's a few reasons this could be that actually aren't unique to PyAutoGUI, many graphics/UI related tools struggle with this sort of issue on retina displays. One possibility is that this is caused by retina displays having higher pixel density. This means that for each point on the screen ("logical pixel") there might be 2x2 physical pixels present. This corresponds to what you're describing as the program recognizing the screen as being half the size that it actually is.

As of September 25, 2023, I'll be trying to address this issue by creating a work around for retina display users. If someone could assign this ticket to me that would be appreciated.

maddox05 commented 1 year ago

yeah its the macbook pro with a retina display. Good explanation, for whatever reason dividing the values by 2 seems to fix going to a point incorrectly, it read the screen half of what Apple "says" it is. The actual size from Apple is 3024 × 1964 and pyautogui.screen() halfs both values.