-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
15bd5ac
commit 52c5511
Showing
4 changed files
with
166 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
on: | ||
push: | ||
branches: | ||
- main | ||
tags: | ||
- 'v*.*.*' | ||
pull_request: {} | ||
env: | ||
COLUMNS: 150 | ||
|
||
jobs: | ||
|
||
build: | ||
runs-on: windows | ||
matrix: | ||
python-version: | ||
- '3.8' | ||
- '3.9' | ||
- '3.10' | ||
- '3.11' | ||
- '3.12' | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: install rust stable | ||
uses: dtolnay/rust-toolchain@stable | ||
|
||
- name: cache rust | ||
uses: Swatinem/rust-cache@v2 | ||
with: | ||
key: test-v0 | ||
|
||
- name: set up python | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
|
||
- name: build wheels | ||
uses: PyO3/maturin-action@v1 | ||
with: | ||
target: ${{ matrix.target }} | ||
args: --release --out dist --interpreter ${{ matrix.python-version || '3.8 3.9 3.10 3.11 3.12 pypy3.9 pypy3.10' }} | ||
rust-toolchain: stable | ||
docker-options: -e CI | ||
|
||
- uses: actions/upload-artifact@v4 | ||
with: | ||
name: pypi_files_${{ matrix.interpreter }} | ||
path: dist | ||
|
||
|
||
|
||
release: | ||
needs: [build] | ||
if: success() && startsWith(github.ref, 'refs/tags/') | ||
runs-on: ubuntu-latest | ||
permissions: | ||
id-token: write | ||
contents: write | ||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: set up python | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version: '3.10' | ||
|
||
- run: pip install -U twine | ||
|
||
|
||
- name: get dist artifacts | ||
uses: actions/download-artifact@v4 | ||
with: | ||
pattern: pypi_files_* | ||
merge-multiple: true | ||
path: dist | ||
|
||
- run: twine check --strict dist/* | ||
|
||
- name: Release PyPI | ||
uses: pypa/gh-action-pypi-publish@release/v1 | ||
|
||
- name: Release GitHub | ||
uses: softprops/action-gh-release@v1 | ||
with: | ||
files: | | ||
dist/* | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
# wmutil | ||
|
||
Utility functions for getting monitor (display) information on Windows. | ||
|
||
|
||
|
||
```python | ||
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 | ||
``` | ||
|
||
Notes: | ||
|
||
- `monitor.size` may not necessarily reflect the monitor's resolution, but rather is the geometry used for drawing or moving windows |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,3 +26,4 @@ classifiers = [ | |
'Operating System :: Microsoft :: Windows', | ||
'Operating System :: MacOS', | ||
] | ||
readme = "README.md" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters