WindowManager: Simplified window management.
Project description
WindowManager This Python package provides a set of functions for managing windows on your system. It utilizes the win32gui and psutil libraries to interact with windows and processes.
Installation The WindowManager package is not currently available on the Python Package Index (PyPI). However, you can install it manually by placing the WindowManager.py file in your project directory.
Usage The WindowManager package offers several functions for manipulating windows and processes. Here’s a breakdown of each function:
windowHandler(hwnd, windows:list): Internal function used for enumerating windows.
getsize(window_title:str): Gets the width and height of a window based on its title.
Arguments:
window_title: The title (or part of the title) of the window you want to get the size of. Returns:
A tuple containing the width and height of the window. Raises:
SyntaxError: If the window with the specified title is not found. ontop(window_title:str, hide=False): Brings a window to the top of the screen or hides it optionally.
Arguments:
window_title: The title (or part of the title) of the window you want to manipulate. hide (optional): A boolean value indicating whether to hide the window (True) or show it on top (False). Defaults to False. Returns:
True if the window is found and manipulated successfully, False otherwise. close(AppName:str): Terminates a program by its process name.
Arguments:
AppName: The name of the process you want to terminate (e.g., “notepad++.exe”). Returns:
True if the process is found and terminated successfully, False otherwise. Raises:
SyntaxError: If the process with the specified name is not found. reposition(window_title:str, y:int, x:int, width:int=-1, height:int=-1): Moves and resizes a window.
Arguments:
window_title: The title (or part of the title) of the window you want to reposition. y: The new y-coordinate (top position) of the window. x: The new x-coordinate (left position) of the window. width (optional): The new width of the window (defaults to the current width if -1). height (optional): The new height of the window (defaults to the current height if -1). Returns:
True if the window is found and repositioned successfully, False otherwise. open(path:str): Opens a program by its file path.
Arguments:
path: The full path to the program’s executable file (e.g., “C:/Program Files/Notepad++/notepad++.exe”). Notes:
The path separator needs to be forward slash (“/”) even on Windows systems. getPID(process_name:str): Gets the process ID (PID) of a running program.
Arguments:
process_name: The name of the process you want to get the PID for (e.g., “notepad++.exe”). Returns:
The PID of the process if found, otherwise raises an error. Raises:
SyntaxError: If the process with the specified name is not found. Examples Here are some examples of how to use the WindowManager functions:
Python import WindowManager
# Get the size of a window titled “Notepad” width, height = WindowManager.getsize(“Notepad”) print(f”Notepad size: {width}x{height}”)
# Bring the window titled “Calculator” on top WindowManager.ontop(“Calculator”)
# Close the program named “notepad++.exe” WindowManager.close(“notepad++.exe”)
# Move the window titled “Command Prompt” to (100, 100) with a width of wm.reposition(“Command Prompt”, 100, 100)
# Open notpad++.exe by its path C:/Program Files/Notepad++ wm.open(‘C:/Program Files/Notepad++’)
# Get the PID of notepad++ by its Process name notpad++.exe wm.getPID(‘notpad++.exe’)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file winmanager-0.0.1.tar.gz
.
File metadata
- Download URL: winmanager-0.0.1.tar.gz
- Upload date:
- Size: 4.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.12.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8ae1a99b651befb38953bb5d6645b7cf977e386994416c507a22e286718ae93a |
|
MD5 | 72d125d4864be2317da2538c97e5d867 |
|
BLAKE2b-256 | 8fb29d8bf819caf52a87fe3e18b277a28422a974f37b555c45f40f9d65382230 |
File details
Details for the file WinManager-0.0.1-py3-none-any.whl
.
File metadata
- Download URL: WinManager-0.0.1-py3-none-any.whl
- Upload date:
- Size: 4.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.12.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 622233796e8f917f7d6459df4e31a9f5a860fa93d28420c9849f2ca1ed4241db |
|
MD5 | 6019cdde4ee6dfd0e613f0eabb2e6d1c |
|
BLAKE2b-256 | 4832af51daf9bcfc35f31563fd2bd09dc55d88b40005dcb17018a06ddd2f2f2c |