Do relative coordinates for a window change depending on the resolution?

1.5k views Asked by At

My colleagues seem to have a lot of trouble using my AHK scripts and it sounds like the MouseClicks are not clicking the right positions within the active windows.

Both parties here are using Windows 7.

Their resolution is 1600 x 900 where as I'm using 1280 x 1024.

I thought the relative positions to a given window would be different so I got my IT people to get 16:9 monitors today for the computer next to mine. Unfortunately the monitors don't support 1600 x 900 resolution and when I noticed that I didn't check the coordinates on those monitors because it wasn't the right resolution.

I was looking around for another way to convert the coordinates to that resolution and found a thread that says converting my coordinates is as simple as:

x1 * 1600/1280 = x2
y1 * 900/1024 = y2

I applied this formula to the MouseClick command coordinates and I tested it on different resolutions and the clicks go to the wrong position everytime.

However, the regular coordinates from my starting resolution still work.

I'm not sure anymore if the coordinates are the problem which is why I'm here asking.

Thank you.

1

There are 1 answers

0
Lexikos On

No. The coordinate system or point of origin is not affected by screen resolution, nor are the coordinates for the window itself.

However, the size or contents of the window may change depending on any number of factors, including screen resolution. It is up to the application.

Window coordinates (the default for most commands in AutoHotkey v1) depend on the current system theme and other settings which affect the size of the window's title bar and borders.

Client coordinates (the default for AutoHotkey v2) are less affected by differences between systems, so are recommended over Window coordinates.

Whatever the coord mode, any values you hard code in the script will need to take into account whatever changes in layout might occur within the application. Again, what those changes are depends on the application.


If the system has multiple monitors and they do not all have the same DPI (scaling), the system "lies" about the coordinates of objects on monitors other than the primary one, unless the program retrieving the coordinates is per-monitor DPI aware. This can cause issues with AutoHotkey, which is not per-monitor DPI aware.