Hello,
I'm getting the wrong IUIAutomation element from the 2nd monitor, if use it in a browser window like edge (which is not the main monitor and has a dpi for i.e. 125% in the windows settings.)
I tried a few things and can't find a working solution.
The following is not working (they are all far above the element under the mouse cursor):
- GetCursorPos
- GetPhysicalCursorPos
- Mousehook (hookStruct.pt.X + " "+ hookStruct.pt.Y)
- PhysicalToLogicalPointForPerMonitorDPI (don't understand how i could get the cursor position since i'm getting the window's data?!)
I've read:
https://learn.microsoft.com/en-us/dotnet/framework/ui-automation/ui-automation-and-screen-scaling
https://support.microsoft.com/en-us/topic/windows-scaling-issues-for-high-dpi-devices-508483cd-7c59-0d08-12b0-960b99aa347d
It's not supported by a method, so i have to calculate it by myself after getting GetCursorPos?! (Getting the dpi, the monitor bounds to offset it against the GetCursorPos.)
[...and while i'm asking, i'm reading that it could be working by SetThreadDpiAwarenessContext function? (because it looks really weird, if my form's dpiAwareness is true). ------ FAILED]
EDIT: I also tried to get the dpi and monitor bounds for calculating it by the following example (gives me really weird data) :
https://stackoverflow.com/questions/29438430/how-to-get-dpi-scale-for-all-screens
Isn't there a solution for just getting the set dpi from the windows settings for the specific monitor and simply calculating the right cursor position for finding the element?!
Regards