Python Forum

Full Version: win32 GetWindowRect for window dimensions
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I am using win32gui.GetWindowRect for a window I have retrieved the handle for using win32.EnumWindows and matching the title of the window as I see on the screen.
I am also using Window Spy to see the same window information.
win32 gives me x of 51, y of 0, width of 1295 and height of 837
Windows Spy gives me x of 77, y of 0, width of 1942 and height 1256

At the moment I am believing Windows Spy as the setting in the running app has screen settings of 1920x1200 which math with the client are in Windows Spy.

My question is what is the correct way to get a windows dimensions?
Quote:My question is what is the correct way to get a windows dimensions?
This is OS dependent, here's something of interest: https://www.blog.pythonlibrary.org/2015/...th-python/
I am sorry but not sure what you mean.
I thought win32 was for Windows only.
I did use the link you provided and saw wxpython and looked for it in VSCode extensions and was not there so tried pip install but when I use import wx I get no module name wx message when I run my py file.
I am not even sure I should be using wxpython as win32 should return the correct information.
It is just that using python and pywin32 I am not getting what I expected and wonder why.
I thought I had found a solution which used Gtk but have not been able to install that as it require pygobject which is failing to install.

I did have some success with ctypes.wintypes which gave me a list of monitors with their sizes but the first one was wrong, the second was correct. I am using tow 4k screens, one in my laptop and the other external via DPio cable.
I have them both set to 2560x1440 as I have found Windows 10 happier that way.
The result of using ctypes.windll.user32 gave me a monitor with size of 1707x960
this coincides with the results of the wintypes first monitor that from using wx
Using win32gui gives me a different story to any other.

I am still searching.