Python Forum
win32 GetWindowRect for window dimensions
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
win32 GetWindowRect for window dimensions
#1
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?
Reply
#2
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/
Reply
#3
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.
Reply
#4
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.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Is there a way to call and focus any popup window outside of the main window app? Valjean 6 1,611 Oct-02-2023, 04:11 PM
Last Post: deanhystad
  Pyspark Window: perform sum over a window with specific conditions Shena76 0 1,131 Jun-13-2022, 08:59 AM
Last Post: Shena76
  Python library for win32 console commands eldiener 3 3,384 Aug-24-2021, 10:28 PM
Last Post: bowlofred
  Win32\ping.exe windows pops up -very annoying... tester_V 9 3,127 Aug-12-2021, 06:54 AM
Last Post: tester_V
Exclamation binwalk Win32 compile hackstunt 2 3,717 Feb-24-2021, 05:14 PM
Last Post: nilamo
  pyarrow throws oserror winerror 193 1 is not a valid win32 application aupres 2 3,722 Oct-21-2020, 01:04 AM
Last Post: aupres
  win32 API: Launch Application to RDP session from background process python script rangeshgupta 0 2,091 May-28-2020, 09:41 PM
Last Post: rangeshgupta
  C:\Windows\System32\appwiz.cpl is not a valid Win32 application Marceepoo 8 5,040 Mar-15-2020, 04:46 AM
Last Post: buran
  Pymssql library failing when upgrading to Python 3.7 - win32 issue stixmagiggins 5 7,351 Jun-24-2019, 06:46 AM
Last Post: snippsat
  Trying to use win32 Sendkeys to log into database overnight statiCat 0 4,132 Apr-28-2018, 03:59 PM
Last Post: statiCat

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020