MathieuT Posted November 3, 2023 Posted November 3, 2023 Hi all, I'm trying to automate a program but I can't access the controls, so I have to rely on the coordinates for MouseClick and PixelGetColor. Everything works as expected on my main external monitor with a resolution of 1680x1050 and scaling set to 100% (Windows 10). The problem is when the window I'm manipulating is active on my laptop screen. The laptop screen has a resolution of 1920x1080 and the scaling is set to 125%. I have no control over the PCs where the script is supposed to run in the end, they may have one or multiple monitors with an unknown scaling factor. So I have to make the script scaling independent. I have already done some research regarding scaling but I can't seem to find a solution. The scaling is also an issue for Au3Info, the magnifier shows a location to the left and above my cursor. This was already mentioned on the forum but it was never solved as far as I know. What I would need is a solution to check the scaling factor on the monitor where the window is active, and use the scaling factor to adjust coordinates I determined on a 100% scale. It would surprise me if nobody else has gotten this issue, but I can't seem to find the solution. FYI, using the code in this post, I get the following output. So my laptop screen (1) is to the left of my external screen (2). The right and bottom positions of the laptop screen are also affected by the scaling (right: -1920 + (1920 / 1.25) / bottom: -27 + (1080 / 1.25)). 0 - L:-1920, T:-27, R:1680, B:1050 1 - L:-1920, T:-27, R:-384, B:837 2 - L:0, T:0, R:1680, B:1050 Thank you in advance.
ioa747 Posted November 3, 2023 Posted November 3, 2023 (edited) take a look if it helps 210826-moves-andor-resizes-and-arrange-windows-between-multi-monitors/ to forum Edited November 3, 2023 by ioa747 I know that I know nothing
MathieuT Posted November 3, 2023 Author Posted November 3, 2023 1 hour ago, ioa747 said: take a look if it helps 210826-moves-andor-resizes-and-arrange-windows-between-multi-monitors/ to forum Thank you for the quick answer. I did some testing with your code and I'm able to use your _MM_GetMonitorsArray() to determine on which monitor the window is active (although in literal edge cases where it is in between monitors it will be wrong...). But the scaling is still off, _MM_GetMonitorsArray() reports back as 1.14285714285714 for the laptop screen which is of course wrong. I used 1.25 to calculate the location of my control based on the location of my window and then it works. While testing I noticed some strange behavior concerning the WinGetPos function, when the window is maximized the position is reported back as "-10, -10" or "-8, -8" or "-7, -7". The width of the window is reported as e.g. 1940 (1920 + 10 + 10). Since I'm using the position of the window to calculate the location of the control, the variance in the window position breaks my code 🤔
argumentum Posted November 3, 2023 Posted November 3, 2023 ..look at my signature. There's HiDpi stuff that may help you. Follow the link to my code contribution ( and other things too ). FAQ - Please Read Before Posting.
MathieuT Posted November 20, 2023 Author Posted November 20, 2023 I know it has been some time, but I have made a lot of progress. I was able to "fix" Au3Info by going in the settings of the executable, so now it is showing the right coordinates, the magnifier is at the correct location... Since then I moved from testing in AutoIt (using SciTE) to programming in C# because I need some C# libraries for the main functionality of the program I am building. Luckily there is AutoItX to use in C#, of course I'm missing some functionalities but until now I always found a C# alternative. I was also able to set the DPI awareness of my C# program so all DPI issues are fixed 🙂 So this topic may be closed.
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now