When AHK uses WinGetPos to get the coordinates of maximized windows, it returns incorrect values.

Get help with using AutoHotkey (v2 or newer) and its commands and hotkeys
Autumn
Posts: 5
Joined: 24 May 2024, 06:20

When AHK uses WinGetPos to get the coordinates of maximized windows, it returns incorrect values.

Post by Autumn » 24 May 2024, 06:29

As the title says, whether I use WinGetPos to get the location of a maximized window in v1 or v2, I get a clearly incorrect value. In my understanding, the coordinates of a maximized window on the main screen should be (0,0) but on my computer I got (-13, -13). As far as I know, different computers will get different values. Also, when I use the function to set the window position to (0,0), the final result will also have some deviation. I don't know whether this is a problem with the Windows system itself or a problem with ahk implementation, but this problem seems to have appeared a long time ago. Many people have found this problem and I hope to update the version to solve this problem as soon as possible, because operating windows and obtaining window information is a very important shortcut function.


[Mod action: Moved topic from “Bug Reports”]

User avatar
boiler
Posts: 17404
Joined: 21 Dec 2014, 02:44

Re: When AHK uses WinGetPos to get the coordinates of maximized windows, it returns incorrect values.

Post by boiler » 24 May 2024, 07:41

Since you’re aware of that history, you might have also seen that it’s not an AHK bug (and it’s not an incorrect value in Windows terms). Perhaps WinGetPosEx would be of interest to you, assuming you haven’t run across it already.

Autumn
Posts: 5
Joined: 24 May 2024, 06:20

Re: When AHK uses WinGetPos to get the coordinates of maximized windows, it returns incorrect values.

Post by Autumn » 25 May 2024, 00:10

boiler wrote:
24 May 2024, 07:41
Since you’re aware of that history, you might have also seen that it’s not an AHK bug (and it’s not an incorrect value in Windows terms). Perhaps WinGetPosEx would be of interest to you, assuming you haven’t run across it already.
I have always thought this is an AHK bug, because I have asked this question in some communication groups, and it seems that many people have encountered this problem. But I really don't know the method of WinGetPosEx, and from your description, it seems to be a problem with the Windows operating system itself. Do you know more specific reasons for this problem? Because I have been looking for the root of this problem for a long time.

User avatar
boiler
Posts: 17404
Joined: 21 Dec 2014, 02:44

Re: When AHK uses WinGetPos to get the coordinates of maximized windows, it returns incorrect values.

Post by boiler » 25 May 2024, 05:16

AHK is relaying the actual window size and position as reported by Windows. Starting with Win10, when Windows renders a window, there is an invisible border around it. The size and position that it reports includes that border. WinGetPosEX is a function that reports the window size and position without the invisible border.

Autumn
Posts: 5
Joined: 24 May 2024, 06:20

Re: When AHK uses WinGetPos to get the coordinates of maximized windows, it returns incorrect values.

Post by Autumn » 30 May 2024, 02:32

boiler wrote:
25 May 2024, 05:16
AHK is relaying the actual window size and position as reported by Windows. Starting with Win10, when Windows renders a window, there is an invisible border around it. The size and position that it reports includes that border. WinGetPosEX is a function that reports the window size and position without the invisible border.
Thank you for your reply. I used the WinGetPosEx function to get the maximized window, but I still got the wrong information. I still got a negative coordinate instead of (0,0) for the maximized window on the main screen.

Post Reply

Return to “Ask for Help (v2)”