No project description provided
Project description
wmutil
Utility functions for getting monitor (display) information on Windows.
Installation
Requires Python 3.8+ and Windows
pip install wmutil
Usage
import wmutil
# Enumerate all monitors
print('Enumerating monitors:')
for monitor in wmutil.enumerate_monitors():
# Print monitor attributes
print(monitor, monitor.name, monitor.size, monitor.position, monitor.refresh_rate_millihertz, monitor.handle, sep='\n\t')
# Get primary monitor
primary_monitor = wmutil.get_primary_monitor()
# Get a monitor based on point coordinates
monitor = wmutil.get_monitor_from_point(0, 0)
# compare monitor objects
if monitor == primary_monitor:
print('it is the primary monitor')
# Get monitor from an HWND
from ahk import AHK # pip install ahk[binary]
ahk = AHK()
window = ahk.active_window
hwnd = int(window.id, 0)
monitor_for_active_window = wmutil.get_window_monitor(hwnd)
print(window.title, 'is using monitor', monitor_for_active_window.name)
Example output:
Enumerating monitors:
<wmutil.Monitor object; handle=491197379>
\\.\DISPLAY1
(1920, 1080)
(-3840, -418)
60000
491197379
<wmutil.Monitor object; handle=85595795>
\\.\DISPLAY2
(3440, 1440)
(0, 0)
60000
85595795
it is the primary monitor
Untitled - Notepad is using monitor \\.\DISPLAY2
Changing the primary monitor:
You can use the set_primary_monitor
function, which accepts a display name or you can use the set_primary
method of a Monitor
object to change the
primary monitor. If the monitor is already the primary monitor, no change will be made and the operation is considered successful. Returns True
when successful and
False
when not successful. If an invalid monitor name is given, an exception is raised.
import wmutil
monitor: wmutil.Monitor # assume this is already defined
wmutil.set_primary_monitor(monitor.name)
# or
monitor.set_primary()
Notes:
monitor.size
may not necessarily reflect the monitor's resolution, but rather is the geometry used for drawing or moving windows
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 Distributions
Built Distributions
File details
Details for the file wmutil-0.2.0-cp312-none-win_amd64.whl
.
File metadata
- Download URL: wmutil-0.2.0-cp312-none-win_amd64.whl
- Upload date:
- Size: 140.7 kB
- Tags: CPython 3.12, Windows x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.0 CPython/3.12.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 64d436e6346aed8c591d243750743e4aac8d3ab51f87274a113865ed8f96e2b1 |
|
MD5 | 07e0922f1c98d0c30b8de29d7d52b588 |
|
BLAKE2b-256 | 3ad2263779231a603f9c58e33f9c77bf891091c01b31b4894275c3a89931412f |
File details
Details for the file wmutil-0.2.0-cp311-none-win_amd64.whl
.
File metadata
- Download URL: wmutil-0.2.0-cp311-none-win_amd64.whl
- Upload date:
- Size: 140.6 kB
- Tags: CPython 3.11, Windows x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.0 CPython/3.12.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e8994fb71bc41c25c2feb130096715d9405017e34a60179a5dc6333fc81a4e69 |
|
MD5 | 0edb3c8ccbcc3af45ce8f4946588071b |
|
BLAKE2b-256 | 927b5c72586ba1ad575fff40d25d4d2617b06cdf7bdd7ef695ebe187950f4b91 |
File details
Details for the file wmutil-0.2.0-cp310-none-win_amd64.whl
.
File metadata
- Download URL: wmutil-0.2.0-cp310-none-win_amd64.whl
- Upload date:
- Size: 141.3 kB
- Tags: CPython 3.10, Windows x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.0 CPython/3.12.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6b81cfa2502ff902366036769974a88b9f562cdf50ac102419c2967f1e1528b4 |
|
MD5 | c10cc855622ed1e4b5134716a3e9725c |
|
BLAKE2b-256 | c19b825d7e1d78b1fc7670ce547405d08d48c2d1a0ad5337f03c8bcf4ad422e7 |
File details
Details for the file wmutil-0.2.0-cp39-none-win_amd64.whl
.
File metadata
- Download URL: wmutil-0.2.0-cp39-none-win_amd64.whl
- Upload date:
- Size: 141.9 kB
- Tags: CPython 3.9, Windows x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.0 CPython/3.12.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 69addc4630a6d9902d8679619e3c8b7e6361a2d6a2fb9b569d6970ab3bde8eca |
|
MD5 | 647e7bcba4cbbdf760d6f83cdafa2d73 |
|
BLAKE2b-256 | 04a78810057e78ce4a834fd40a7b2360c03900bdf6e06f289c9581885e2797d1 |
File details
Details for the file wmutil-0.2.0-cp38-none-win_amd64.whl
.
File metadata
- Download URL: wmutil-0.2.0-cp38-none-win_amd64.whl
- Upload date:
- Size: 141.6 kB
- Tags: CPython 3.8, Windows x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.0 CPython/3.12.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e04b4bddd78c40c9f5d27c0f47caaf10b3014c23772e3aa398f5b8d77f3644ce |
|
MD5 | 52eeb4aaa39706b2fcf90c8b1b292e70 |
|
BLAKE2b-256 | ed7fa6706d0aceadc2a8824d25b487c34123f3995ded34d31a3df6d3736ec890 |