Skip to main content

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

windowmanager-0.0.1.tar.gz (4.0 kB view details)

Uploaded Source

Built Distribution

WindowManager-0.0.1-py3-none-any.whl (4.3 kB view details)

Uploaded Python 3

File details

Details for the file windowmanager-0.0.1.tar.gz.

File metadata

  • Download URL: windowmanager-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

Hashes for windowmanager-0.0.1.tar.gz
Algorithm Hash digest
SHA256 7163bbf86939339a6935edac7e9dee4df7e4311621cb78d9db9a801a6811bfea
MD5 a0d7bc049bdea241b19aab8195c8653c
BLAKE2b-256 cf7f4f72c6fc251815332df8c7c838038691a34bd0c5633b27ee7b64110f37a5

See more details on using hashes here.

File details

Details for the file WindowManager-0.0.1-py3-none-any.whl.

File metadata

File hashes

Hashes for WindowManager-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 b85b30c238b2482b94ef12f6216f031b7e50831cecdc50f307329b0c11742206
MD5 fb6d6aca8e214635afae8a8f5a2d4de6
BLAKE2b-256 0f6008c8460dd446b80cb3f9dfac77b1b4796f5aa98b11482515b7858bc43d4b

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page