How to get a list of the name of every open window?

You can use win32gui.GetWindowText( hwnd ) along with win32gui.EnumWindows: import win32gui def winEnumHandler( hwnd, ctx ): if win32gui.IsWindowVisible( hwnd ): print ( hex( hwnd ), win32gui.GetWindowText( hwnd ) ) win32gui.EnumWindows( winEnumHandler, None ) Output: 0x20fa4 bet – [C:\Users\X\Desktop\] – [bet] – L:\stack\stack_enum_windows.py – IntelliJ IDEA 2017.2.5 0x1932478 13. vnc 888 0x30c27b8 Telegram (55) 0x40aba MobaXterm … Read more

How do I find position of a Win32 control/window relative to its parent window?

The solution is using the combined power of GetWindowRect() and MapWindowPoints(). GetWindowRect() retrieves the coordinates of a window relative to the entire screen area you see on your monitor. We need to convert these absolute coordinates into relative coordinates of our main window area. The MapWindowPoints() transforms the coordinates given relative to one window into … Read more

Screenshot of inactive window PrintWindow + win32gui

After lots of searching and trying various different methods, the following worked for me. import win32gui import win32ui from ctypes import windll import Image hwnd = win32gui.FindWindow(None, ‘Calculator’) # Change the line below depending on whether you want the whole window # or just the client area. #left, top, right, bot = win32gui.GetClientRect(hwnd) left, top, … Read more