Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a way to move a window to another monitor using Python?

Tags:

python

windows

I need to get a handle to a Window and then move it to my secondary monitor. Is this doable with python 2.6, preferably using the standard libraries.

like image 588
Joan Venge Avatar asked Nov 24 '11 02:11

Joan Venge


People also ask

How do I move a window in Python?

Python OpenCV – moveWindow() Function If we want to show image windows at a specific position moveWindow() function of OpenCV will do it. Parameters: window_name: name of the window which you want to move at particular position. x: Value of x coordinate.

How do I move active window to another monitor?

Alt+Tab: Open task switcher. Windows+P: Will duplicate your screen/extend your desktop to an additional monitor. Windows+Shift+Left or Right Arrow: Move a window from one monitor to another.

How do I move a window to another screen without seeing it?

Hold down the Shift key, then right-click on the appropriate application icon in the Windows taskbar. On the resulting pop-up, select the Move option. Begin pressing the arrow keys on your keyboard to move the invisible window from off-screen to on-screen.


1 Answers

Use the pywin32 module to access the native Win32 API. The functions you'll need to use are:

  • EnumWindows to enumerate all of the top-level windows in the system; search for the one you want and save off the window handle
  • EnumDisplayMonitors to enumerate all of the monitors in the system
  • GetMonitorInfo to get the virtual display coordinates of a monitor and to determine whether or not each monitor is the primary monitor
  • MoveWindow to move the window to the desired virtual display coordinates, using the window handle you found earlier
like image 195
Adam Rosenfield Avatar answered Nov 15 '22 13:11

Adam Rosenfield