Skip to main content

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)

Metadata

Release files for win-pos 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for win-pos 0.1.0
File Size Uploaded
win-pos-0.1.0.tar.gz 2.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for win-pos 0.1.0
File Interpreter ABI Platform
win_pos-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 5.6 kB

Release files / win-pos-0.1.0.tar.gz

Download URL win-pos-0.1.0.tar.gz
Size 2.8 kB
Tags Source
SHA-256 checksum
How to use checksums
f36aba05294a99eac2f87d0a2c7511de22286a9b177aa1a06c1f63ae9a8f248e
BLAKE2b-256 checksum
How to use checksums
3fd36afb8b10b02c08ca29c2e6656cc98f1228ff311f94e2449022a1cfac0e8a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.1

Release files / win_pos-0.1.0-py3-none-any.whl

Download URL win_pos-0.1.0-py3-none-any.whl
Size 2.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
1317ad7ef8db5a00f31f483d8b9b7f59c261c4a7f46b1ac7d53c1fcf9556419f
BLAKE2b-256 checksum
How to use checksums
3271b63df8943eb39b5138517a7557ba07a064d7634626dd0289d978c38106e9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.1

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files

0.0.2

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page