Add utility methods that allow you to easily grab the position of a window
Project description
A tiny Python utility library used to get the bounds of an application window.
The get_window_pos
function takes either a string, or a callable
where the first argument is a string and that returns a boolean.
As an example, we'll get the position of Discord. As Discord's window title
can vary depending on what server and channel you're in, we'll take advantage
of the expected callable and pass a lambda to see if the window ends with 'Discord'
.
from WinPos import get_window_pos
get_window_pos(lambda title: title.endswith('Discord'))
# (619, 473, 1624, 716)
Not all windows are as complicated as Discord, fortunately. If the window you're trying to get the position of is static and never changes, you can simply pass a string through and get your value.
from WinPos import get_window_pos
get_window_pos('Task Manager')
# (125, 117, 895, 726)
If for whatever reason you need to repeatedly get the position of the same window,
you can import get_window_hwnd
and get_window_pos_from_hwnd
functions. This will
save some time from not having to iterate over every application to check the title.
from WinPos import get_window_hwnd, get_window_pos_from_hwnd
hwnd = get_window_hwnd('Task Manager')
get_window_pos_from_hwnd(hwnd)
# (125, 117, 895, 726)
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 win-pos-0.1.0.tar.gz
.
File metadata
- Download URL: win-pos-0.1.0.tar.gz
- Upload date:
- Size: 2.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f36aba05294a99eac2f87d0a2c7511de22286a9b177aa1a06c1f63ae9a8f248e |
|
MD5 | ca8adf9d094db773ef71b2da0556bd4d |
|
BLAKE2b-256 | 3fd36afb8b10b02c08ca29c2e6656cc98f1228ff311f94e2449022a1cfac0e8a |
File details
Details for the file win_pos-0.1.0-py3-none-any.whl
.
File metadata
- Download URL: win_pos-0.1.0-py3-none-any.whl
- Upload date:
- Size: 2.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1317ad7ef8db5a00f31f483d8b9b7f59c261c4a7f46b1ac7d53c1fcf9556419f |
|
MD5 | dcc669c4fdad2cb15752658a8b7d5009 |
|
BLAKE2b-256 | 3271b63df8943eb39b5138517a7557ba07a064d7634626dd0289d978c38106e9 |