Skip to main content

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

Metadata

Release files for wmutil 0.3.0

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

Built distributions (wheels)

Table of built distributions (wheels) for wmutil 0.3.0
File
wmutil-0.3.0-cp313-cp313-win_amd64.whl CPython 3.13 CPython 3.13 Windows x86-64 Details
wmutil-0.3.0-cp312-cp312-win_amd64.whl CPython 3.12 CPython 3.12 Windows x86-64 Details
wmutil-0.3.0-cp311-cp311-win_amd64.whl CPython 3.11 CPython 3.11 Windows x86-64 Details
wmutil-0.3.0-cp310-cp310-win_amd64.whl CPython 3.10 CPython 3.10 Windows x86-64 Details
wmutil-0.3.0-cp39-cp39-win_amd64.whl CPython 3.9 CPython 3.9 Windows x86-64 Details
wmutil-0.3.0-cp38-cp38-win_amd64.whl CPython 3.8 CPython 3.8 Windows x86-64 Details

Total release size: 831.6 kB

Release files / wmutil-0.3.0-cp313-cp313-win_amd64.whl

Download URL wmutil-0.3.0-cp313-cp313-win_amd64.whl
Size 138.6 kB
Tags CPython 3.13 Windows x86-64
SHA-256 checksum
How to use checksums
895e4ff05aedd33d8d6e5eb7047b0ae9a9108e308c97f82bda90b8534201f8d2
BLAKE2b-256 checksum
How to use checksums
9f08488b862f8c757f83dfe6c1725ec3dc898e2c634c04d96ced2a1b009988c6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.0.1 CPython/3.12.8

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jan 22, 2025.

Transparency log

Release files / wmutil-0.3.0-cp312-cp312-win_amd64.whl

Download URL wmutil-0.3.0-cp312-cp312-win_amd64.whl
Size 138.4 kB
Tags CPython 3.12 Windows x86-64
SHA-256 checksum
How to use checksums
16a20858746e5a695fdeb63b5ccba7826b5fb962a01404c10927b3e6d917b0e9
BLAKE2b-256 checksum
How to use checksums
40e912329e7d7ce87d598aa479ccf961cf4dfabbefe79dca73cfdf40ab43ace3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.0.1 CPython/3.12.8

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jan 22, 2025.

Transparency log

Release files / wmutil-0.3.0-cp311-cp311-win_amd64.whl

Download URL wmutil-0.3.0-cp311-cp311-win_amd64.whl
Size 138.4 kB
Tags CPython 3.11 Windows x86-64
SHA-256 checksum
How to use checksums
c7ec489303109288f77ef612f0f46c44b1e797464e45f6b13a03565d3a8f354a
BLAKE2b-256 checksum
How to use checksums
92776b4d423617daed467318d4af3e2820d7fcfffd3fcd88c2765a734785aa25
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.0.1 CPython/3.12.8

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jan 22, 2025.

Transparency log

Release files / wmutil-0.3.0-cp310-cp310-win_amd64.whl

Download URL wmutil-0.3.0-cp310-cp310-win_amd64.whl
Size 138.3 kB
Tags CPython 3.10 Windows x86-64
SHA-256 checksum
How to use checksums
c86937e411c26d70b7723f9c1e443165db8c7239b88df369828189fba33bfeae
BLAKE2b-256 checksum
How to use checksums
de77d028e52a2dfea30534d5d8ff2db8c3b8b23935481346a46ee224def79c66
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.0.1 CPython/3.12.8

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jan 22, 2025.

Transparency log

Release files / wmutil-0.3.0-cp39-cp39-win_amd64.whl

Download URL wmutil-0.3.0-cp39-cp39-win_amd64.whl
Size 139.0 kB
Tags CPython 3.9 Windows x86-64
SHA-256 checksum
How to use checksums
b4f99800f1ca5fa6c13a58d8dfa8a3bb3135db086dd93b1e1efa07b371678557
BLAKE2b-256 checksum
How to use checksums
ccc391187a6fa534de3e29ebe41f449c1f11c70dcebd7f3225451aeac19bdfbd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.0.1 CPython/3.12.8

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jan 22, 2025.

Transparency log

Release files / wmutil-0.3.0-cp38-cp38-win_amd64.whl

Download URL wmutil-0.3.0-cp38-cp38-win_amd64.whl
Size 139.1 kB
Tags CPython 3.8 Windows x86-64
SHA-256 checksum
How to use checksums
d0c691ea35130c0877bb84acd341ad9becf794694525c6bb28668e940b7e380d
BLAKE2b-256 checksum
How to use checksums
6adf8a90eec98cf6d6a00dc93472b1dd34f76d8c5588f8eb65a4a9716627b8b0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.0.1 CPython/3.12.8

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jan 22, 2025.

Transparency log

Release history Release notifications | RSS feed

This release

0.3.0 This release

6 release files

0.2.0

5 release files

0.1.1

5 release files

0.1.0

5 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