This script was born out of frustration: when I had a TV connected to my Windows PC as a second monitor, and the TV was turned off, Windows still treated it as active. New windows would open on the dark screen, making them inaccessible.
This Python utility solves that problem by allowing you to interactively move any visible window to your primary screen. It's lightweight, terminal-based, and easy to extend.
- Lists all windows with visible titles.
- Allows user to select a window by number.
- Moves the selected window to the top-left corner of the main screen.
- Designed for Windows environments with multiple monitors.
- Python 3.7+
pygetwindow
pip install pygetwindow
-
Run the script:
python move_window.py
-
You'll see a numbered list of windows with titles.
-
Type the number of the window you want to move.
-
The window will be repositioned to
(0, 0)on your primary display.
Witch window move to main screen?
1 - Google Chrome
2 - Visual Studio Code
3 - Spotify
In the list are displayed only windows with Name
Type the number of the window: 2
Window "Visual Studio Code" will be moved to the top-left of your main screen.
import pygetwindow as gw
def list_window_names():
return gw.getAllTitles()
def list_positions_of_window():
list = list_window_names()
pos = []
i = 1
for window_name in list:
window = gw.getWindowsWithTitle(window_name)[0]
pos.append((i, window_name, window, window.top, window.left))
i += 1
return pos
def main():
print("Witch window move to main screen?")
for row in list_positions_of_window():
if row[1] != "":
print(str(row[0]).rjust(5), " - ", row[1])
print("In the list are displayed only windows with Name")
odpoved = input("Type the number of the window: ")
for window in list_positions_of_window():
if odpoved == str(window[0]):
print(window)
window[2].moveTo(0, 0)
if __name__ == "__main__":
main()This script will be expanded based on user feedback. Planned features include:
- Auto-detection of off-screen windows.
- Centering windows on the main screen.
- Integration with Windows context menu (right-click).
- GUI version with mouse-based selection.
Feel free to open an issue or submit a pull request if you have ideas or requests!
MIT License – free to use, modify, and distribute.