Get other running processes window sizes in Python

Using hints from WindowMover article and Nattee Niparnan’s blog post I managed to create this: import win32con import win32gui def isRealWindow(hWnd): ”’Return True iff given window is a real Windows application window.”’ if not win32gui.IsWindowVisible(hWnd): return False if win32gui.GetParent(hWnd) != 0: return False hasNoOwner = win32gui.GetWindow(hWnd, win32con.GW_OWNER) == 0 lExStyle = win32gui.GetWindowLong(hWnd, win32con.GWL_EXSTYLE) if (((lExStyle … Read more

What can you do with COM/ActiveX in Python? [closed]

First you have to install the wonderful pywin32 module. It provides COM support. You need to run the makepy utility. It is located at C:\…\Python26\Lib\site-packages\win32com\client. On Vista, it must be ran with admin rights. This utility will show all available COM objects. You can find yours and it will generate a python wrapper for this … Read more

GetWindowRect too small on Windows 7

My first thoughts were listed below but if, as you state, you’re certain that GetWindowRect is returning incorrect values, see RESOLUTION further down. “What’s wrong with GetSystemMetrics(SM_CXBORDER) and GetSystemMetrics(SM_CYBORDER)? The method you’re using seems a very roundabout way of doing it and, if you can call GetWindowRect(), I’m pretty certain you can call GetSystemMetrics() as … Read more

Symlinks on windows?

NTFS file system has junction points, I think you may use them instead, You can use python win32 API module for that e.g. import win32file win32file.CreateSymbolicLink(fileSrc, fileTarget, 1) If you do not want to rely on win32API module, you can always use ctypes and directly call CreateSymbolicLink win32 API e.g. import ctypes kdll = ctypes.windll.LoadLibrary(“kernel32.dll”) … Read more

How to get Windows’ special folders for currently logged-in user?

Should you wish to do it without the win32 extensions, you can use ctypes to call SHGetFolderPath: >>> import ctypes.wintypes >>> CSIDL_PERSONAL= 5 # My Documents >>> SHGFP_TYPE_CURRENT= 0 # Want current, not default value >>> buf= ctypes.create_unicode_buffer(ctypes.wintypes.MAX_PATH) >>> ctypes.windll.shell32.SHGetFolderPathW(0, CSIDL_PERSONAL, 0, SHGFP_TYPE_CURRENT, buf) 0 >>> buf.value u’C:\\Documents and Settings\\User\\My Documents’

PyWin32 and Python 3.8.0

Spoiler alert!!! Applied #2.2. (from below) to the original .whls, and published them on [GitHub]: CristiFati/Prebuilt-Binaries – (master) Prebuilt-Binaries/PyWin32/v225 (win_amd64, win32 for Python 3.8). After installing (one of) them, existing code should work OOTB (with respect to this issue). Install steps: Download the .whl that matches your Python architecture (64bit, 32bit – for more details … Read more

tech