-
Notifications
You must be signed in to change notification settings - Fork 28
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
Screen scaling factor (Screen Scaling on Windows / Retina Display on Mac) #62
Comments
damies13
added a commit
to damies13/robotframework-imagehorizonlibrary
that referenced
this issue
Feb 26, 2022
This update will now detect the screen scaling ratio and adjust accordingly. I tested it using "tests/atest/calculator.robot" on a mac with a Retina display running OSX 12.0.1 I don't have a windows machine to test on, but based on comments in [pyautogui issue #589](asweigart/pyautogui#589) this should work for the various windows scaling ratios. This replaces the self.has_retina which wasn't working as it was returning false on my machine even though it does indeed have a retina display. __get_pixel_ratio should only get called the first time _locate is called, that was my experience in testing, though perhaps it should be called every time as windows users could potentially change their display scaling during the test. Also I don't know of an OS that supports it now but I guess it's possible in the future an OS may have a scaling factor less than 100% and this change won't support that either. Issue eficode#62
noubar
added a commit
to noubar/Robotframework-ImageLibrary
that referenced
this issue
Oct 17, 2024
commit 6cc09dd Author: Dave Amies <damies13@gmail.com> Date: Sat Feb 26 14:09:19 2022 +1000 My tweaks to atest to make it run locally commit 2dd9d9d Author: Dave Amies <damies13@gmail.com> Date: Sat Feb 26 14:07:38 2022 +1000 Will now detect the screen scaling ratio and adjust This update will now detect the screen scaling ratio and adjust accordingly. I tested it using "tests/atest/calculator.robot" on a mac with a Retina display running OSX 12.0.1 I don't have a windows machine to test on, but based on comments in [pyautogui issue #589](asweigart/pyautogui#589) this should work for the various windows scaling ratios. This replaces the self.has_retina which wasn't working as it was returning false on my machine even though it does indeed have a retina display. __get_pixel_ratio should only get called the first time _locate is called, that was my experience in testing, though perhaps it should be called every time as windows users could potentially change their display scaling during the test. Also I don't know of an OS that supports it now but I guess it's possible in the future an OS may have a scaling factor less than 100% and this change won't support that either. Issue eficode#62
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Well this is frustrating,
I was trying to set up some basic tests for issues #60 and #61 before I start making changes and I encountered the "retina display issue" when trying to use
Click Image
.Did a little research, and found that the upstream pyautogui is the cause, there is a known issue for this #589 where a workaround is provided so they closed the issue, so it looks like if we want IHL to behave as users would expect then we need to handle it by implementing the workaround.
I also found this issue impacts Windows machines when screen scaling is enabled, while on Mac's the Retina display means the co-ordinates are always double (200%) what they need to be, with windows the scaling factor can vary between 100% and 500% times with typical values being 125%, 150%, 175%, 200%
Fortunately the workaround provided
pixelRatio = pyautogui.screenshot().size[0]/pyautogui.size().width
does give us the ratio, so it's a simple matter of dividing the x and y values from pyautogui by the pixelRatio and returning the new co-ordinates.Also fortunately the workaround doesn't need any additional python modules so it's a minimal impact.
I will submit a fix for this issue soon.
The text was updated successfully, but these errors were encountered: