How can I get a windows-oriented window and resize it?

I want to get a focused window to change it ... how can I do this?

+7
python windows
source share
1 answer

Use the GetForegroundWindow Win32 API to get a window handle.

Then use the MoveWindow (or SetWindowPos , if you prefer) win32 API to resize the window.

Working with the Win32 API can be done directly using ctypes and working with dll or using the pywin32 project.

Edit: Of course, here is an example ( Make sure pywin32 is installed ):

import win32gui hwnd = win32gui.GetForegroundWindow() win32gui.MoveWindow(hwnd, 0, 0, 500, 500, True) 
+9
source share

All Articles