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

Two screens with different DPI settings. #9

Open
thepragmatic15 opened this issue May 1, 2023 · 3 comments
Open

Two screens with different DPI settings. #9

thepragmatic15 opened this issue May 1, 2023 · 3 comments

Comments

@thepragmatic15
Copy link

Is it possible to force UIAViewer to adapt to screens that are not set to the same settings (DPI)?
My laptop screen is usually set to 125% (DPI), while my 2nd screen is set to 100%.
For UIAViewer to work correctly on both screens (switching from one screen to another),
I have to set both screens to either (100% or 125% DPI).
If not, UIA Viewer will not be able to correctly find the items I want to find.
The blue selection square will not correspond to the coordinates sought.

@thepragmatic15
Copy link
Author

What a lack of recognition on my part!
First of all, I should have thanked you Descolada, for the immense work you do with UIA Viewer.
All the time you devote to it, allows us to save hours of work.
Thank you very much, this tool is like a magic formula that allows us to quickly accomplish tasks that otherwise would be almost impossible to accomplish effectively. We are immensely grateful.

@Descolada
Copy link
Owner

@thepragmatic15 thanks for the kind words!

I am aware of the DPI issue, and if I remember correctly then it should be solvable by adding DllCall("SetThreadDpiAwarenessContext", "ptr", -4, "ptr") to the top of Viewer class __New method (line 6707).

What it doesn't solve is the coordinate problems everywhere else: using Highlight() or getting the coordinates with Element.Location or Element.BoundingRectangle. I haven't been able to think of a good solution other than checking the DPI awareness context before every call of those methods, but that would cause additional problems. For example, if you were to get the element location with one DPI awareness, but try to use MouseMove with another, then the coordinates wouldn't match. If you were to globally change it (place it at the top of the script), then it would break any previous implementations relying on the current one.
Also I am currently unable to test this issue further at the moment, because I don't have a second monitor available. I will leave this issue open, so I can take another look at it at some point.

@Descolada
Copy link
Owner

@thepragmatic15 the issue appears to be fixed in recent Chromium builds, are you able to confirm? I tested with latest Chrome and Edge in Windows 10 and elements were highlighted correctly. This was not the case for all Chromium apps such as Discord, but I figure the app creators just need time to update the Chromium engines.

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

2 participants