Skip to main content

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


Download files

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

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

wmutil-0.3.0-cp313-cp313-win_amd64.whl (138.6 kB view details)

Uploaded CPython 3.13Windows x86-64

wmutil-0.3.0-cp312-cp312-win_amd64.whl (138.4 kB view details)

Uploaded CPython 3.12Windows x86-64

wmutil-0.3.0-cp311-cp311-win_amd64.whl (138.4 kB view details)

Uploaded CPython 3.11Windows x86-64

wmutil-0.3.0-cp310-cp310-win_amd64.whl (138.3 kB view details)

Uploaded CPython 3.10Windows x86-64

wmutil-0.3.0-cp39-cp39-win_amd64.whl (139.0 kB view details)

Uploaded CPython 3.9Windows x86-64

wmutil-0.3.0-cp38-cp38-win_amd64.whl (139.1 kB view details)

Uploaded CPython 3.8Windows x86-64

File details

Details for the file wmutil-0.3.0-cp313-cp313-win_amd64.whl.

File metadata

  • Download URL: wmutil-0.3.0-cp313-cp313-win_amd64.whl
  • Upload date:
  • Size: 138.6 kB
  • Tags: CPython 3.13, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.0.1 CPython/3.12.8

File hashes

Hashes for wmutil-0.3.0-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 895e4ff05aedd33d8d6e5eb7047b0ae9a9108e308c97f82bda90b8534201f8d2
MD5 09872fd2ca10d5fd641b63ac7d1b4f96
BLAKE2b-256 9f08488b862f8c757f83dfe6c1725ec3dc898e2c634c04d96ced2a1b009988c6

See more details on using hashes here.

Provenance

The following attestation bundles were made for wmutil-0.3.0-cp313-cp313-win_amd64.whl:

Publisher: build.yaml on spyoungtech/wmutil

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file wmutil-0.3.0-cp312-cp312-win_amd64.whl.

File metadata

  • Download URL: wmutil-0.3.0-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 138.4 kB
  • Tags: CPython 3.12, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.0.1 CPython/3.12.8

File hashes

Hashes for wmutil-0.3.0-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 16a20858746e5a695fdeb63b5ccba7826b5fb962a01404c10927b3e6d917b0e9
MD5 5bdcbed93e7c8241e3bdbc134afe33e9
BLAKE2b-256 40e912329e7d7ce87d598aa479ccf961cf4dfabbefe79dca73cfdf40ab43ace3

See more details on using hashes here.

Provenance

The following attestation bundles were made for wmutil-0.3.0-cp312-cp312-win_amd64.whl:

Publisher: build.yaml on spyoungtech/wmutil

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file wmutil-0.3.0-cp311-cp311-win_amd64.whl.

File metadata

  • Download URL: wmutil-0.3.0-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 138.4 kB
  • Tags: CPython 3.11, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.0.1 CPython/3.12.8

File hashes

Hashes for wmutil-0.3.0-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 c7ec489303109288f77ef612f0f46c44b1e797464e45f6b13a03565d3a8f354a
MD5 e3953fa678cf7a6eba9bb398df8537ed
BLAKE2b-256 92776b4d423617daed467318d4af3e2820d7fcfffd3fcd88c2765a734785aa25

See more details on using hashes here.

Provenance

The following attestation bundles were made for wmutil-0.3.0-cp311-cp311-win_amd64.whl:

Publisher: build.yaml on spyoungtech/wmutil

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file wmutil-0.3.0-cp310-cp310-win_amd64.whl.

File metadata

  • Download URL: wmutil-0.3.0-cp310-cp310-win_amd64.whl
  • Upload date:
  • Size: 138.3 kB
  • Tags: CPython 3.10, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.0.1 CPython/3.12.8

File hashes

Hashes for wmutil-0.3.0-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 c86937e411c26d70b7723f9c1e443165db8c7239b88df369828189fba33bfeae
MD5 ed37596ce7c7d9d4b12ef1282dd8e630
BLAKE2b-256 de77d028e52a2dfea30534d5d8ff2db8c3b8b23935481346a46ee224def79c66

See more details on using hashes here.

Provenance

The following attestation bundles were made for wmutil-0.3.0-cp310-cp310-win_amd64.whl:

Publisher: build.yaml on spyoungtech/wmutil

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file wmutil-0.3.0-cp39-cp39-win_amd64.whl.

File metadata

  • Download URL: wmutil-0.3.0-cp39-cp39-win_amd64.whl
  • Upload date:
  • Size: 139.0 kB
  • Tags: CPython 3.9, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.0.1 CPython/3.12.8

File hashes

Hashes for wmutil-0.3.0-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 b4f99800f1ca5fa6c13a58d8dfa8a3bb3135db086dd93b1e1efa07b371678557
MD5 2e62aa8b46e393cc052915a4367a04a3
BLAKE2b-256 ccc391187a6fa534de3e29ebe41f449c1f11c70dcebd7f3225451aeac19bdfbd

See more details on using hashes here.

Provenance

The following attestation bundles were made for wmutil-0.3.0-cp39-cp39-win_amd64.whl:

Publisher: build.yaml on spyoungtech/wmutil

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file wmutil-0.3.0-cp38-cp38-win_amd64.whl.

File metadata

  • Download URL: wmutil-0.3.0-cp38-cp38-win_amd64.whl
  • Upload date:
  • Size: 139.1 kB
  • Tags: CPython 3.8, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.0.1 CPython/3.12.8

File hashes

Hashes for wmutil-0.3.0-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 d0c691ea35130c0877bb84acd341ad9becf794694525c6bb28668e940b7e380d
MD5 4ba37e912b2b8aa70de0c0b234d8eba9
BLAKE2b-256 6adf8a90eec98cf6d6a00dc93472b1dd34f76d8c5588f8eb65a4a9716627b8b0

See more details on using hashes here.

Provenance

The following attestation bundles were made for wmutil-0.3.0-cp38-cp38-win_amd64.whl:

Publisher: build.yaml on spyoungtech/wmutil

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

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