GetWindowPlacement() different values for windows in the exact same location

Coptil David 0 Reputation points
2024-07-30T22:18:25.2566667+00:00

Why does GetWindowPlacement() give different coordinates for two applications that are positioned in the exact same location.

So I opened three different windows of Chrome, and placed them on the exact location all three. One on top of the other. In code (in python) I just print the placement of the current selected window with: print( win32gui.GetWindowPlacement( win32gui.GetForegroundWindow() ) )

When I go through them, the printed coordinates change for each one... why is that? they are places in the exact same location, same width/height, even the same application...

This is what I get in the console:

window 1: (0, 1, (-1, -1), (-1, -1), (193, 484, 1995, 2034))

window 2: (0, 1, (-1, -1), (-1, -1), (1067, 307, 2870, 1858))

window 3: (0, 1, (-1, -1), (-1, -1), (466, 133, 2271, 1686))

The thing I am trying to do is to open a chrome window at that speciffic location from this pyhton script.. But with the problem from above it is impossible, because the coordinates seem to change everytime.

I think I have to specify that I have 3 monitors, with different scaling(two - 1080p and one - 4k). but in the case specified above, all windows were opened on the same monitor, so I don;t think the scaling is the problem in this case.

Windows API - Win32
Windows API - Win32
A core set of Windows application programming interfaces (APIs) for desktop and server applications. Previously known as Win32 API.
2,526 questions
{count} votes