Skip to content

Frantik111/Move-Window-to-Main-Screen

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 

Repository files navigation

🪟 Move Window to Main Screen – Python Utility

Overview

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.


🔧 Features

  • 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.

🐍 Requirements

Installation

pip install pygetwindow

▶️ How to Use

  1. Run the script:

    python move_window.py
  2. You'll see a numbered list of windows with titles.

  3. Type the number of the window you want to move.

  4. The window will be repositioned to (0, 0) on your primary display.


💡 Example Output

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.


📦 Source Code

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()

🚀 Future Plans

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!


📄 License

MIT License – free to use, modify, and distribute.

About

Move any visible window to your primary screen

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages