Uses ctypes to get the resolution and other useful information of all available monitors
pip install getmonitorresolution
Tested against Windows 10 / Python 3.10 / Anaconda
The get_monitors_resolution() function retrieves the resolution information of all available monitors on a Windows machine. It takes an optional parameter dpi_awareness, which sets the DPI awareness level. The function returns a tuple containing two dictionaries, allmoni and moninfos.
allmoni is a dictionary containing the resolution details of all available monitors, with the monitor index as the key. The values of the dictionary are also dictionaries containing the width and height of each monitor.
moninfos is a dictionary containing the following resolution information of all the available monitors:
width_all_monitors: The combined width of all the monitors.
height_all_monitors: The maximum height among all the monitors.
max_monitor_width: The maximum width of all the monitors.
min_monitor_width: The minimum width of all the monitors.
max_monitor_height: The maximum height of all the monitors.
min_monitor_height: The minimum height of all the monitors.
def get_monitors_resolution(dpi_awareness=2):
"""
Retrieves the resolution information of all the available monitors and returns the resolution details in a dictionary format.
Args:
dpi_awareness (int): Optional parameter to set DPI awareness level. Default is 2, which is the highest level of DPI awareness.
Returns:
tuple: A tuple containing two dictionaries, `allmoni` and `moninfos`.
- `allmoni` (dict): A dictionary containing the resolution details of all available monitors, with the monitor index as key.
- `moninfos` (dict): A dictionary containing the following resolution information of all the available monitors:
* width_all_monitors (int): The combined width of all the monitors.
* height_all_monitors (int): The maximum height among all the monitors.
* max_monitor_width (int): The maximum width of all the monitors.
* min_monitor_width (int): The minimum width of all the monitors.
* max_monitor_height (int): The maximum height of all the monitors.
* min_monitor_height (int): The minimum height of all the monitors.
from getmonitorresolution import get_monitors_resolution
eachmonitor,general = get_monitors_resolution()
print(eachmonitor)
print(general)
# output
eachmonitor,general = get_monitors_resolution()
from pprint import pprint
pprint(eachmonitor)
{0: {'DeviceID': 'PCI\\VEN_10DE&DEV_1F06&Sxxxxxxxxxxxxxxxxx&REV_A1',
'DeviceKey': '\\Registry\\Machine\\System\\CurrentControlSet\\Control\\Video\\{xxxxxxxxxxxxxx}\\0000',
'DeviceName': '\\\\.\\DISPLAY1',
'DeviceString': 'NVIDIA GeForce RTX 2060 SUPER',
'StateFlags': 5,
'height': 1080,
'height_mm': 299,
'is_primary': True,
'width': 1920,
'width_mm': 531,
'x': 0,
'y': 0},
1: {'DeviceID': 'PCI\\VEN_10DE&xxxxxxxx&xxxxxxxxxxxxx&REV_A1',
'DeviceKey': '\\Registry\\Machine\\System\\CurrentControlSet\\Control\\Video\\{xxxxxxxxxxxx}\\0001',
'DeviceName': '\\\\.\\DISPLAY2',
'DeviceString': 'NVIDIA GeForce RTX 2060 SUPER',
'StateFlags': 1,
'height': 1080,
'height_mm': 299,
'is_primary': False,
'width': 1920,
'width_mm': 531,
'x': 1920,
'y': 0}}
pprint(general)
{'height_all_monitors': 2160,
'max_monitor_height': 1080,
'max_monitor_width': 1920,
'min_monitor_height': 1080,
'min_monitor_width': 1920,
'width_all_monitors': 3840}
Metadata
Release files for getmonitorresolution 0.13
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| getmonitorresolution-0.13.tar.gz | 6.1 kB | Without provenance | Details for getmonitorresolution-0.13.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| getmonitorresolution-0.13-py3-none-any.whl | Python 3 | none | any | Details for getmonitorresolution-0.13-py3-none-any.whl |
Total release size: 13.5 kB
Release files / getmonitorresolution-0.13.tar.gz
| Download URL | getmonitorresolution-0.13.tar.gz |
|---|---|
| Size | 6.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
eb556a05bffba5e6aca12288024026a806fe6c71b5baf185e787058aab0834c7
|
|
BLAKE2b-256 checksum How to use checksums |
2766a45d5696245d4c2f741e4a725a1adbb1c5e14e16b383cc630b77611bfd08
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.10.10
|
Release files / getmonitorresolution-0.13-py3-none-any.whl
| Download URL | getmonitorresolution-0.13-py3-none-any.whl |
|---|---|
| Size | 7.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
41d8655521a9b35329ab9593bcf312c76e84e886527f3dc843c0040af6e7dd8a
|
|
BLAKE2b-256 checksum How to use checksums |
d529dd9b0b48368f5a50e7f1f93de0147fdb61f40f85b9a1f6f1f6dfdb9e8341
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.10.10
|
Security for getmonitorresolution 0.13
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.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.