wintegrate 0.1.0a1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- wintegrate-0.1.0a1/.github/workflows/ci.yml +169 -0
- wintegrate-0.1.0a1/.github/workflows/publish.yml +80 -0
- wintegrate-0.1.0a1/.gitignore +18 -0
- wintegrate-0.1.0a1/.mailmap +1 -0
- wintegrate-0.1.0a1/LICENSE +21 -0
- wintegrate-0.1.0a1/PKG-INFO +197 -0
- wintegrate-0.1.0a1/README.md +161 -0
- wintegrate-0.1.0a1/pyproject.toml +77 -0
- wintegrate-0.1.0a1/src/wintegrate/__init__.py +76 -0
- wintegrate-0.1.0a1/src/wintegrate/apps.py +100 -0
- wintegrate-0.1.0a1/src/wintegrate/diagnostics.py +287 -0
- wintegrate-0.1.0a1/src/wintegrate/element.py +529 -0
- wintegrate-0.1.0a1/src/wintegrate/env.py +105 -0
- wintegrate-0.1.0a1/src/wintegrate/exceptions.py +43 -0
- wintegrate-0.1.0a1/src/wintegrate/interop.py +395 -0
- wintegrate-0.1.0a1/src/wintegrate/recorder.py +234 -0
- wintegrate-0.1.0a1/src/wintegrate/session.py +468 -0
- wintegrate-0.1.0a1/src/wintegrate/text.py +36 -0
- wintegrate-0.1.0a1/src/wintegrate/window.py +281 -0
- wintegrate-0.1.0a1/tests/conftest.py +19 -0
- wintegrate-0.1.0a1/tests/test_census.py +26 -0
- wintegrate-0.1.0a1/tests/test_desktop_uwp_calculator.py +90 -0
- wintegrate-0.1.0a1/tests/test_e2e_notepad.py +23 -0
- wintegrate-0.1.0a1/tests/test_integrated_e2e.py +82 -0
- wintegrate-0.1.0a1/tests/test_multi_window.py +137 -0
- wintegrate-0.1.0a1/tests/test_recorder_and_inspect.py +76 -0
- wintegrate-0.1.0a1/tests/test_replace_pywinauto.py +61 -0
- wintegrate-0.1.0a1/tests/test_text_and_exceptions.py +37 -0
- wintegrate-0.1.0a1/uv.lock +456 -0
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
name: CI UI Automation Tests
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: [ main ]
|
|
6
|
+
pull_request:
|
|
7
|
+
branches: [ main ]
|
|
8
|
+
|
|
9
|
+
jobs:
|
|
10
|
+
lint:
|
|
11
|
+
runs-on: windows-latest
|
|
12
|
+
steps:
|
|
13
|
+
- uses: actions/checkout@v6
|
|
14
|
+
|
|
15
|
+
- name: Set up Python
|
|
16
|
+
uses: actions/setup-python@v7
|
|
17
|
+
with:
|
|
18
|
+
python-version: "3.13"
|
|
19
|
+
|
|
20
|
+
- name: Install dependencies
|
|
21
|
+
run: |
|
|
22
|
+
python -m pip install --upgrade pip
|
|
23
|
+
pip install ruff
|
|
24
|
+
|
|
25
|
+
- name: Run Ruff Lint & Format Check
|
|
26
|
+
run: |
|
|
27
|
+
ruff check src/ tests/
|
|
28
|
+
ruff format --check src/ tests/
|
|
29
|
+
|
|
30
|
+
test-x64:
|
|
31
|
+
needs: lint
|
|
32
|
+
runs-on: windows-latest
|
|
33
|
+
strategy:
|
|
34
|
+
fail-fast: false
|
|
35
|
+
matrix:
|
|
36
|
+
python-version: ["3.11", "3.12", "3.13", "3.14"]
|
|
37
|
+
|
|
38
|
+
steps:
|
|
39
|
+
- uses: actions/checkout@v6
|
|
40
|
+
|
|
41
|
+
- name: Set up Python ${{ matrix.python-version }}
|
|
42
|
+
uses: actions/setup-python@v7
|
|
43
|
+
with:
|
|
44
|
+
python-version: ${{ matrix.python-version }}
|
|
45
|
+
|
|
46
|
+
- name: Install dependencies
|
|
47
|
+
run: |
|
|
48
|
+
python -m pip install --upgrade pip
|
|
49
|
+
pip install -e .[dev]
|
|
50
|
+
|
|
51
|
+
- name: Run unit & live GUI recording tests
|
|
52
|
+
run: |
|
|
53
|
+
pytest tests/ -v -s
|
|
54
|
+
|
|
55
|
+
- name: Upload Recording Artifacts & Diagnostics
|
|
56
|
+
if: always()
|
|
57
|
+
uses: actions/upload-artifact@v6
|
|
58
|
+
with:
|
|
59
|
+
name: ci-artifacts-x64-py${{ matrix.python-version }}
|
|
60
|
+
path: |
|
|
61
|
+
recording-artifacts/
|
|
62
|
+
artifacts/
|
|
63
|
+
if-no-files-found: ignore
|
|
64
|
+
|
|
65
|
+
test-arm64:
|
|
66
|
+
needs: lint
|
|
67
|
+
runs-on: windows-11-arm
|
|
68
|
+
strategy:
|
|
69
|
+
fail-fast: false
|
|
70
|
+
matrix:
|
|
71
|
+
# GitHub Actions setup-python provides official Windows ARM64 builds for Python 3.11+
|
|
72
|
+
python-version: ["3.11", "3.12", "3.13", "3.14"]
|
|
73
|
+
|
|
74
|
+
steps:
|
|
75
|
+
- uses: actions/checkout@v6
|
|
76
|
+
|
|
77
|
+
- name: Install WSL on ARM Runner (Stop 30s probe popups)
|
|
78
|
+
shell: pwsh
|
|
79
|
+
run: |
|
|
80
|
+
# 1. Update WSL stub so the provision daemon stops spawning terminal popups every 30s
|
|
81
|
+
$p = Start-Process -FilePath wsl.exe -ArgumentList '--update', '--confirm' -NoNewWindow -PassThru
|
|
82
|
+
if (-not $p.WaitForExit(60000)) { $p.Kill(); Write-Host 'wsl --update timed out' }
|
|
83
|
+
|
|
84
|
+
# 2. Fallback to arm64 MSI if needed
|
|
85
|
+
function Get-WslStatus {
|
|
86
|
+
$prev = [Console]::OutputEncoding
|
|
87
|
+
try {
|
|
88
|
+
[Console]::OutputEncoding = [System.Text.Encoding]::Unicode
|
|
89
|
+
return ((& wsl.exe --status 2>&1 | Out-String) -replace "\0", '')
|
|
90
|
+
} finally { [Console]::OutputEncoding = $prev }
|
|
91
|
+
}
|
|
92
|
+
$status = Get-WslStatus
|
|
93
|
+
Write-Host "WSL status: $status"
|
|
94
|
+
if ($status -match 'not installed') {
|
|
95
|
+
try {
|
|
96
|
+
$rel = Invoke-RestMethod 'https://api.github.com/repos/microsoft/WSL/releases/latest'
|
|
97
|
+
$asset = $rel.assets | Where-Object { $_.name -match 'arm64\.msi$' } | Select-Object -First 1
|
|
98
|
+
if ($asset) {
|
|
99
|
+
Write-Host "Downloading $($asset.name)..."
|
|
100
|
+
Invoke-WebRequest -Uri $asset.browser_download_url -OutFile wsl-arm64.msi
|
|
101
|
+
Start-Process msiexec -ArgumentList '/i', 'wsl-arm64.msi', '/qn', '/norestart' -Wait
|
|
102
|
+
}
|
|
103
|
+
} catch {
|
|
104
|
+
Write-Host "WSL MSI fallback skipped: $_"
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
# 3. Disable Microsoft Edge First Run Experience via Registry
|
|
109
|
+
New-Item -Path "HKLM:\SOFTWARE\Policies\Microsoft\Edge" -Force -ErrorAction SilentlyContinue
|
|
110
|
+
Set-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Edge" -Name "HideFirstRunExperience" -Value 1 -Type DWord -Force -ErrorAction SilentlyContinue
|
|
111
|
+
Set-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Edge" -Name "PreventFirstRunPage" -Value 1 -Type DWord -Force -ErrorAction SilentlyContinue
|
|
112
|
+
New-Item -Path "HKCU:\SOFTWARE\Policies\Microsoft\Edge" -Force -ErrorAction SilentlyContinue
|
|
113
|
+
Set-ItemProperty -Path "HKCU:\SOFTWARE\Policies\Microsoft\Edge" -Name "HideFirstRunExperience" -Value 1 -Type DWord -Force -ErrorAction SilentlyContinue
|
|
114
|
+
|
|
115
|
+
# 4. Sweep existing background popups
|
|
116
|
+
Get-Process -Name "wsl","wslhost","WindowsTerminal","msedge","msedgewebview2" -ErrorAction SilentlyContinue | Stop-Process -Force -ErrorAction SilentlyContinue
|
|
117
|
+
$global:LASTEXITCODE = 0
|
|
118
|
+
|
|
119
|
+
# Python 3.12+ ships pre-installed in the windows-11-arm image's tool cache,
|
|
120
|
+
# but 3.11 does not: setup-python downloads and installs it on every run
|
|
121
|
+
# (~90s). Cache the installed toolchain so later runs restore it instead.
|
|
122
|
+
- name: Cache Python ${{ matrix.python-version }} toolchain
|
|
123
|
+
if: matrix.python-version == '3.11'
|
|
124
|
+
uses: actions/cache@v4
|
|
125
|
+
with:
|
|
126
|
+
path: C:\hostedtoolcache\windows\Python\3.11*
|
|
127
|
+
key: python-toolchain-winarm64-${{ matrix.python-version }}
|
|
128
|
+
|
|
129
|
+
- name: Set up Python ${{ matrix.python-version }}
|
|
130
|
+
uses: actions/setup-python@v7
|
|
131
|
+
with:
|
|
132
|
+
python-version: ${{ matrix.python-version }}
|
|
133
|
+
|
|
134
|
+
- name: Install FFmpeg on Windows ARM64
|
|
135
|
+
continue-on-error: true
|
|
136
|
+
shell: pwsh
|
|
137
|
+
run: |
|
|
138
|
+
# Use official BtbN winarm64 static build for native performance
|
|
139
|
+
try {
|
|
140
|
+
$ProgressPreference = 'SilentlyContinue'
|
|
141
|
+
Invoke-WebRequest -Uri "https://github.com/BtbN/FFmpeg-Builds/releases/download/latest/ffmpeg-master-latest-winarm64-gpl.zip" -OutFile ffmpeg-arm64.zip
|
|
142
|
+
Expand-Archive -Path ffmpeg-arm64.zip -DestinationPath ffmpeg-arm64 -Force
|
|
143
|
+
$binDir = Get-ChildItem -Path ffmpeg-arm64 -Filter bin -Recurse -Directory | Select-Object -First 1 -ExpandProperty FullName
|
|
144
|
+
Write-Host "Native ARM64 FFmpeg at: $binDir"
|
|
145
|
+
Add-Content -Path $env:GITHUB_PATH -Value $binDir
|
|
146
|
+
} catch {
|
|
147
|
+
Write-Host "ARM64 FFmpeg download fallback to Chocolatey"
|
|
148
|
+
choco install ffmpeg -y --no-progress
|
|
149
|
+
Add-Content -Path $env:GITHUB_PATH -Value "C:\ProgramData\chocolatey\bin"
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
- name: Install dependencies
|
|
153
|
+
run: |
|
|
154
|
+
python -m pip install --upgrade pip
|
|
155
|
+
pip install -e .[dev]
|
|
156
|
+
|
|
157
|
+
- name: Run unit & live GUI recording tests
|
|
158
|
+
run: |
|
|
159
|
+
pytest tests/ -v -s
|
|
160
|
+
|
|
161
|
+
- name: Upload Recording Artifacts & Diagnostics
|
|
162
|
+
if: always()
|
|
163
|
+
uses: actions/upload-artifact@v6
|
|
164
|
+
with:
|
|
165
|
+
name: ci-artifacts-arm64-py${{ matrix.python-version }}
|
|
166
|
+
path: |
|
|
167
|
+
recording-artifacts/
|
|
168
|
+
artifacts/
|
|
169
|
+
if-no-files-found: ignore
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
name: Publish to PyPI
|
|
2
|
+
|
|
3
|
+
# Publishes on a GitHub Release, or on demand via workflow_dispatch (TestPyPI by
|
|
4
|
+
# default there, so a dry run never burns a real version number).
|
|
5
|
+
on:
|
|
6
|
+
release:
|
|
7
|
+
types: [published]
|
|
8
|
+
workflow_dispatch:
|
|
9
|
+
inputs:
|
|
10
|
+
target:
|
|
11
|
+
description: Package index to publish to
|
|
12
|
+
type: choice
|
|
13
|
+
options: [testpypi, pypi]
|
|
14
|
+
default: testpypi
|
|
15
|
+
|
|
16
|
+
jobs:
|
|
17
|
+
build:
|
|
18
|
+
runs-on: ubuntu-latest
|
|
19
|
+
steps:
|
|
20
|
+
- uses: actions/checkout@v6
|
|
21
|
+
|
|
22
|
+
- name: Set up Python
|
|
23
|
+
uses: actions/setup-python@v7
|
|
24
|
+
with:
|
|
25
|
+
python-version: "3.13"
|
|
26
|
+
|
|
27
|
+
- name: Build sdist and wheel
|
|
28
|
+
run: |
|
|
29
|
+
python -m pip install --upgrade pip build
|
|
30
|
+
python -m build
|
|
31
|
+
|
|
32
|
+
- name: Verify metadata and long description render
|
|
33
|
+
run: |
|
|
34
|
+
python -m pip install twine
|
|
35
|
+
python -m twine check --strict dist/*
|
|
36
|
+
|
|
37
|
+
# A release tag must match the version in pyproject.toml, otherwise the
|
|
38
|
+
# published artifact silently disagrees with the tag people cite.
|
|
39
|
+
- name: Check tag matches package version
|
|
40
|
+
if: github.event_name == 'release'
|
|
41
|
+
run: |
|
|
42
|
+
VERSION=$(python -c 'import tomllib,pathlib;print(tomllib.loads(pathlib.Path("pyproject.toml").read_text())["project"]["version"])')
|
|
43
|
+
TAG="${GITHUB_REF_NAME#v}"
|
|
44
|
+
echo "pyproject version: $VERSION / tag: $TAG"
|
|
45
|
+
test "$VERSION" = "$TAG"
|
|
46
|
+
|
|
47
|
+
- uses: actions/upload-artifact@v6
|
|
48
|
+
with:
|
|
49
|
+
name: dist
|
|
50
|
+
path: dist/
|
|
51
|
+
|
|
52
|
+
publish-testpypi:
|
|
53
|
+
needs: build
|
|
54
|
+
if: github.event_name == 'workflow_dispatch' && inputs.target == 'testpypi'
|
|
55
|
+
runs-on: ubuntu-latest
|
|
56
|
+
environment: testpypi
|
|
57
|
+
permissions:
|
|
58
|
+
id-token: write # OIDC token for Trusted Publishing; no API token stored
|
|
59
|
+
steps:
|
|
60
|
+
- uses: actions/download-artifact@v6
|
|
61
|
+
with:
|
|
62
|
+
name: dist
|
|
63
|
+
path: dist/
|
|
64
|
+
- uses: pypa/gh-action-pypi-publish@release/v1
|
|
65
|
+
with:
|
|
66
|
+
repository-url: https://test.pypi.org/legacy/
|
|
67
|
+
|
|
68
|
+
publish-pypi:
|
|
69
|
+
needs: build
|
|
70
|
+
if: github.event_name == 'release' || (github.event_name == 'workflow_dispatch' && inputs.target == 'pypi')
|
|
71
|
+
runs-on: ubuntu-latest
|
|
72
|
+
environment: pypi
|
|
73
|
+
permissions:
|
|
74
|
+
id-token: write # OIDC token for Trusted Publishing; no API token stored
|
|
75
|
+
steps:
|
|
76
|
+
- uses: actions/download-artifact@v6
|
|
77
|
+
with:
|
|
78
|
+
name: dist
|
|
79
|
+
path: dist/
|
|
80
|
+
- uses: pypa/gh-action-pypi-publish@release/v1
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Mango Yen <mango.yen.tw@gmail.com> mangokingTW <mangokingtw@gmail.com>
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Mango Yen
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: wintegrate
|
|
3
|
+
Version: 0.1.0a1
|
|
4
|
+
Summary: CI-first Windows UI automation library designed for unattended headless/CI runners.
|
|
5
|
+
Project-URL: Homepage, https://github.com/mangokingTW/wintegrate
|
|
6
|
+
Project-URL: Repository, https://github.com/mangokingTW/wintegrate
|
|
7
|
+
Project-URL: Issues, https://github.com/mangokingTW/wintegrate/issues
|
|
8
|
+
Project-URL: Changelog, https://github.com/mangokingTW/wintegrate/releases
|
|
9
|
+
Author-email: Mango Yen <mango.yen.tw@gmail.com>
|
|
10
|
+
License-Expression: MIT
|
|
11
|
+
License-File: LICENSE
|
|
12
|
+
Keywords: arm64,ci,gui-testing,testing,ui-automation,uia,windows
|
|
13
|
+
Classifier: Development Status :: 3 - Alpha
|
|
14
|
+
Classifier: Environment :: Win32 (MS Windows)
|
|
15
|
+
Classifier: Intended Audience :: Developers
|
|
16
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
17
|
+
Classifier: Operating System :: Microsoft :: Windows
|
|
18
|
+
Classifier: Programming Language :: Python :: 3
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
22
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
23
|
+
Classifier: Topic :: Software Development :: Quality Assurance
|
|
24
|
+
Classifier: Topic :: Software Development :: Testing
|
|
25
|
+
Requires-Python: >=3.11
|
|
26
|
+
Requires-Dist: comtypes>=1.4.16
|
|
27
|
+
Requires-Dist: imageio-ffmpeg>=0.6.0
|
|
28
|
+
Requires-Dist: pillow>=12.3.0
|
|
29
|
+
Requires-Dist: psutil>=7.2.2
|
|
30
|
+
Requires-Dist: pyvda>=0.6.0
|
|
31
|
+
Provides-Extra: dev
|
|
32
|
+
Requires-Dist: pytest-cov>=7.1.0; extra == 'dev'
|
|
33
|
+
Requires-Dist: pytest>=9.1.1; extra == 'dev'
|
|
34
|
+
Requires-Dist: ruff>=0.16.5; extra == 'dev'
|
|
35
|
+
Description-Content-Type: text/markdown
|
|
36
|
+
|
|
37
|
+
# wintegrate
|
|
38
|
+
|
|
39
|
+
A Python library for driving Windows GUIs **from CI**, where no human is watching and the only evidence of what happened is whatever the run left behind.
|
|
40
|
+
|
|
41
|
+
[](https://github.com/mangokingTW/wintegrate/actions/workflows/ci.yml)
|
|
42
|
+
[](https://pypi.org/project/wintegrate/)
|
|
43
|
+
[](https://github.com/mangokingTW/wintegrate)
|
|
44
|
+
[](https://github.com/astral-sh/ruff)
|
|
45
|
+
|
|
46
|
+
---
|
|
47
|
+
|
|
48
|
+
## Why wintegrate?
|
|
49
|
+
|
|
50
|
+
Most Windows GUI automation frameworks (e.g. `pywinauto`, `pyautogui`) are built for interactive desktop use on developer workstations. In unattended CI runners (`windows-latest`, `windows-11-arm`), standard interactive assumptions break down:
|
|
51
|
+
|
|
52
|
+
- **Fail-safes panic in CI**: Moving the cursor into a corner panics interactive libraries and halts test runs.
|
|
53
|
+
- **Stale COM wrappers**: Reusing resolved UI element references across seconds causes silent `COMError` failures.
|
|
54
|
+
- **Launcher PID != Window PID**: Modern packaged Windows apps (like Notepad, Terminal) launch a starter shim process that does not own the visible HWND.
|
|
55
|
+
- **Memory & Pipe Deadlocks**: In-memory frame capture exhausts RAM; streaming with unbuffered `stderr` pipes deadlocks subprocesses.
|
|
56
|
+
- **ARM64 Scancode & Input Drops**: DirectX scan-code simulation fails on Windows ARM64 virtualization; keypresses are dropped without verification.
|
|
57
|
+
- **Multi-Window Discovery Collision**: Launching multiple instances of identical apps causes discovery diffs to select the existing instance rather than the new one.
|
|
58
|
+
- **Unverified fire-and-forget**: Typing without post-condition assertions hides silent failures (e.g. counting `\n` while Notepad returns `\r\n` or `\r`).
|
|
59
|
+
|
|
60
|
+
`wintegrate` is engineered specifically for **unattended CI reliability** across both **x64 and ARM64 Windows**.
|
|
61
|
+
|
|
62
|
+
---
|
|
63
|
+
|
|
64
|
+
## Core Features & Architecture
|
|
65
|
+
|
|
66
|
+
### 1. Verified Actions & Post-Conditions
|
|
67
|
+
Every UI interaction confirms its post-condition (line count deltas, buffer content, focus transitions) before returning:
|
|
68
|
+
```python
|
|
69
|
+
editor.type_verified(
|
|
70
|
+
"Hello from CI\nSecond line\n",
|
|
71
|
+
expected_line_count_delta=2,
|
|
72
|
+
verify_contains="Hello from CI\nSecond line",
|
|
73
|
+
delay_per_char=0.03,
|
|
74
|
+
)
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
### 2. Universal x64 & ARM64 Native Unicode Input
|
|
78
|
+
Replaced DirectX scan-code simulation with native Win32 `SendInput` utilizing `KEYEVENTF_UNICODE`. Seamlessly injects special characters, linebreaks, and multibyte Unicode across both Intel/AMD x64 and Windows 11 ARM64 virtualization runners.
|
|
79
|
+
|
|
80
|
+
### 3. Multi-Window Isolation & Discovery Exclusion
|
|
81
|
+
Supports launching and discovering multiple concurrent instances of the same application without PID/HWND collisions:
|
|
82
|
+
```python
|
|
83
|
+
with session.app(NOTEPAD) as app_a:
|
|
84
|
+
# exclude_hwnds guarantees discovery finds the new window, not the existing one.
|
|
85
|
+
# fresh=False: the leftover sweep would otherwise kill Window A.
|
|
86
|
+
with session.app(NOTEPAD, fresh=False, exclude_hwnds={app_a.window.hwnd}) as app_b:
|
|
87
|
+
app_a.find_text_input().type_verified("Window A\n", expected_line_count_delta=1)
|
|
88
|
+
app_b.find_text_input().type_verified("Window B\n", expected_line_count_delta=1)
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
### 4. Non-Invasive Thread Input Focus (`AttachThreadInput`)
|
|
92
|
+
Switches foreground focus cleanly using `AttachThreadInput` synchronization between the automation thread and the target window thread. Grants activation authority without invasive keystrokes or Z-order corruption.
|
|
93
|
+
|
|
94
|
+
### 5. Windows 11 Virtual Desktop Clean-Room Isolation (`pyvda`)
|
|
95
|
+
Supports dynamic virtual desktop isolation. When `isolated_virtual_desktop=True`, `wintegrate` creates a clean virtual desktop on the fly, switches to it, executes test operations in isolation away from background noise, and automatically destroys the test desktop on exit.
|
|
96
|
+
|
|
97
|
+
### 6. Streaming Video & Diagnostic Pipeline
|
|
98
|
+
- **Low-Memory Streaming Recorder**: Streams desktop frames directly to FFmpeg subprocess (`ContinuousRecorder`) with `stderr` redirected to disk logs.
|
|
99
|
+
- **Automatic Failure Artifacts**: Automatically dumps full-screen screenshots and pre/post `window_census.json` diffs on assertion failure.
|
|
100
|
+
- **Event Timeline Logging**: Logs action timestamps and targets to human-readable `.log` and structured `.json`.
|
|
101
|
+
|
|
102
|
+
### 7. Managed App Lifecycle & Locale-Independent Discovery (`session.app`)
|
|
103
|
+
Modern Windows apps break naive launch-and-poll automation in specific, repeatable ways.
|
|
104
|
+
`session.app()` packages the countermeasures:
|
|
105
|
+
|
|
106
|
+
```python
|
|
107
|
+
from wintegrate import NOTEPAD, Session, SessionConfig
|
|
108
|
+
|
|
109
|
+
with Session(SessionConfig()) as session:
|
|
110
|
+
with session.app(NOTEPAD) as app: # cleanup guaranteed, even on failure
|
|
111
|
+
editor = app.find_text_input() # locale-independent control ladder
|
|
112
|
+
editor.type_verified("hello\n", expected_line_count_delta=1)
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
- **No localized strings**: windows are matched by process image name (`Notepad.exe`),
|
|
116
|
+
window class (`Notepad`), and UIA control types — none of which change with the UI
|
|
117
|
+
language. Title regexes are a last-resort fallback and live once, in the `AppSpec`.
|
|
118
|
+
- **Single-instance safety**: Store apps (Notepad) reuse a running instance — a leaked
|
|
119
|
+
instance makes the next launch open a *tab* instead of a new window, and discovery
|
|
120
|
+
times out mysteriously. `fresh="auto"` sweeps leftovers before launching (CI only).
|
|
121
|
+
- **Cold-start headroom**: first launches of Store apps regularly exceed 10s on CI
|
|
122
|
+
runners (ARM64 especially); managed launches default to a 30s discovery timeout.
|
|
123
|
+
- **No leaks**: the context manager closes the window and kills the process on exit,
|
|
124
|
+
and a timed-out discovery kills its own launcher.
|
|
125
|
+
|
|
126
|
+
---
|
|
127
|
+
|
|
128
|
+
## Quickstart
|
|
129
|
+
|
|
130
|
+
```python
|
|
131
|
+
from wintegrate import NOTEPAD, Session, SessionConfig
|
|
132
|
+
|
|
133
|
+
config = SessionConfig(
|
|
134
|
+
artifact_dir="./ci-artifacts",
|
|
135
|
+
record_video=True,
|
|
136
|
+
fps=30,
|
|
137
|
+
)
|
|
138
|
+
|
|
139
|
+
with Session(config) as session:
|
|
140
|
+
# Managed lifecycle: locale-independent discovery, single-instance safety,
|
|
141
|
+
# generous cold-start timeout, and guaranteed cleanup on exit.
|
|
142
|
+
with session.app(NOTEPAD) as app:
|
|
143
|
+
editor = app.find_text_input()
|
|
144
|
+
|
|
145
|
+
# Types hardware keystrokes and verifies line count delta & text content
|
|
146
|
+
editor.type_verified(
|
|
147
|
+
"Hello from CI\nSecond line\n",
|
|
148
|
+
expected_line_count_delta=2,
|
|
149
|
+
verify_contains="Hello from CI\nSecond line",
|
|
150
|
+
)
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
---
|
|
154
|
+
|
|
155
|
+
## Installation
|
|
156
|
+
|
|
157
|
+
```bash
|
|
158
|
+
pip install wintegrate
|
|
159
|
+
# or
|
|
160
|
+
uv add wintegrate
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
Pre-release versions (`0.1.0aN`) are not installed by default — ask for them explicitly:
|
|
164
|
+
```bash
|
|
165
|
+
pip install --pre wintegrate
|
|
166
|
+
uv add --prerelease=allow wintegrate
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
Or install from source with development dependencies:
|
|
170
|
+
```bash
|
|
171
|
+
git clone https://github.com/mangokingTW/wintegrate.git
|
|
172
|
+
cd wintegrate
|
|
173
|
+
pip install -e .[dev]
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
Windows only: the package imports on other platforms (so cross-platform tooling and
|
|
177
|
+
`env` checks work), but every Win32/UIA call raises a clear unsupported-platform error.
|
|
178
|
+
|
|
179
|
+
---
|
|
180
|
+
|
|
181
|
+
## Running Tests
|
|
182
|
+
|
|
183
|
+
Run full test suite locally:
|
|
184
|
+
```powershell
|
|
185
|
+
pytest tests/ -v -s
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
Run static code analysis & formatting check:
|
|
189
|
+
```powershell
|
|
190
|
+
ruff check src/ tests/
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
---
|
|
194
|
+
|
|
195
|
+
## License
|
|
196
|
+
|
|
197
|
+
MIT License. See [LICENSE](LICENSE) for details.
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
# wintegrate
|
|
2
|
+
|
|
3
|
+
A Python library for driving Windows GUIs **from CI**, where no human is watching and the only evidence of what happened is whatever the run left behind.
|
|
4
|
+
|
|
5
|
+
[](https://github.com/mangokingTW/wintegrate/actions/workflows/ci.yml)
|
|
6
|
+
[](https://pypi.org/project/wintegrate/)
|
|
7
|
+
[](https://github.com/mangokingTW/wintegrate)
|
|
8
|
+
[](https://github.com/astral-sh/ruff)
|
|
9
|
+
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
## Why wintegrate?
|
|
13
|
+
|
|
14
|
+
Most Windows GUI automation frameworks (e.g. `pywinauto`, `pyautogui`) are built for interactive desktop use on developer workstations. In unattended CI runners (`windows-latest`, `windows-11-arm`), standard interactive assumptions break down:
|
|
15
|
+
|
|
16
|
+
- **Fail-safes panic in CI**: Moving the cursor into a corner panics interactive libraries and halts test runs.
|
|
17
|
+
- **Stale COM wrappers**: Reusing resolved UI element references across seconds causes silent `COMError` failures.
|
|
18
|
+
- **Launcher PID != Window PID**: Modern packaged Windows apps (like Notepad, Terminal) launch a starter shim process that does not own the visible HWND.
|
|
19
|
+
- **Memory & Pipe Deadlocks**: In-memory frame capture exhausts RAM; streaming with unbuffered `stderr` pipes deadlocks subprocesses.
|
|
20
|
+
- **ARM64 Scancode & Input Drops**: DirectX scan-code simulation fails on Windows ARM64 virtualization; keypresses are dropped without verification.
|
|
21
|
+
- **Multi-Window Discovery Collision**: Launching multiple instances of identical apps causes discovery diffs to select the existing instance rather than the new one.
|
|
22
|
+
- **Unverified fire-and-forget**: Typing without post-condition assertions hides silent failures (e.g. counting `\n` while Notepad returns `\r\n` or `\r`).
|
|
23
|
+
|
|
24
|
+
`wintegrate` is engineered specifically for **unattended CI reliability** across both **x64 and ARM64 Windows**.
|
|
25
|
+
|
|
26
|
+
---
|
|
27
|
+
|
|
28
|
+
## Core Features & Architecture
|
|
29
|
+
|
|
30
|
+
### 1. Verified Actions & Post-Conditions
|
|
31
|
+
Every UI interaction confirms its post-condition (line count deltas, buffer content, focus transitions) before returning:
|
|
32
|
+
```python
|
|
33
|
+
editor.type_verified(
|
|
34
|
+
"Hello from CI\nSecond line\n",
|
|
35
|
+
expected_line_count_delta=2,
|
|
36
|
+
verify_contains="Hello from CI\nSecond line",
|
|
37
|
+
delay_per_char=0.03,
|
|
38
|
+
)
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
### 2. Universal x64 & ARM64 Native Unicode Input
|
|
42
|
+
Replaced DirectX scan-code simulation with native Win32 `SendInput` utilizing `KEYEVENTF_UNICODE`. Seamlessly injects special characters, linebreaks, and multibyte Unicode across both Intel/AMD x64 and Windows 11 ARM64 virtualization runners.
|
|
43
|
+
|
|
44
|
+
### 3. Multi-Window Isolation & Discovery Exclusion
|
|
45
|
+
Supports launching and discovering multiple concurrent instances of the same application without PID/HWND collisions:
|
|
46
|
+
```python
|
|
47
|
+
with session.app(NOTEPAD) as app_a:
|
|
48
|
+
# exclude_hwnds guarantees discovery finds the new window, not the existing one.
|
|
49
|
+
# fresh=False: the leftover sweep would otherwise kill Window A.
|
|
50
|
+
with session.app(NOTEPAD, fresh=False, exclude_hwnds={app_a.window.hwnd}) as app_b:
|
|
51
|
+
app_a.find_text_input().type_verified("Window A\n", expected_line_count_delta=1)
|
|
52
|
+
app_b.find_text_input().type_verified("Window B\n", expected_line_count_delta=1)
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
### 4. Non-Invasive Thread Input Focus (`AttachThreadInput`)
|
|
56
|
+
Switches foreground focus cleanly using `AttachThreadInput` synchronization between the automation thread and the target window thread. Grants activation authority without invasive keystrokes or Z-order corruption.
|
|
57
|
+
|
|
58
|
+
### 5. Windows 11 Virtual Desktop Clean-Room Isolation (`pyvda`)
|
|
59
|
+
Supports dynamic virtual desktop isolation. When `isolated_virtual_desktop=True`, `wintegrate` creates a clean virtual desktop on the fly, switches to it, executes test operations in isolation away from background noise, and automatically destroys the test desktop on exit.
|
|
60
|
+
|
|
61
|
+
### 6. Streaming Video & Diagnostic Pipeline
|
|
62
|
+
- **Low-Memory Streaming Recorder**: Streams desktop frames directly to FFmpeg subprocess (`ContinuousRecorder`) with `stderr` redirected to disk logs.
|
|
63
|
+
- **Automatic Failure Artifacts**: Automatically dumps full-screen screenshots and pre/post `window_census.json` diffs on assertion failure.
|
|
64
|
+
- **Event Timeline Logging**: Logs action timestamps and targets to human-readable `.log` and structured `.json`.
|
|
65
|
+
|
|
66
|
+
### 7. Managed App Lifecycle & Locale-Independent Discovery (`session.app`)
|
|
67
|
+
Modern Windows apps break naive launch-and-poll automation in specific, repeatable ways.
|
|
68
|
+
`session.app()` packages the countermeasures:
|
|
69
|
+
|
|
70
|
+
```python
|
|
71
|
+
from wintegrate import NOTEPAD, Session, SessionConfig
|
|
72
|
+
|
|
73
|
+
with Session(SessionConfig()) as session:
|
|
74
|
+
with session.app(NOTEPAD) as app: # cleanup guaranteed, even on failure
|
|
75
|
+
editor = app.find_text_input() # locale-independent control ladder
|
|
76
|
+
editor.type_verified("hello\n", expected_line_count_delta=1)
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
- **No localized strings**: windows are matched by process image name (`Notepad.exe`),
|
|
80
|
+
window class (`Notepad`), and UIA control types — none of which change with the UI
|
|
81
|
+
language. Title regexes are a last-resort fallback and live once, in the `AppSpec`.
|
|
82
|
+
- **Single-instance safety**: Store apps (Notepad) reuse a running instance — a leaked
|
|
83
|
+
instance makes the next launch open a *tab* instead of a new window, and discovery
|
|
84
|
+
times out mysteriously. `fresh="auto"` sweeps leftovers before launching (CI only).
|
|
85
|
+
- **Cold-start headroom**: first launches of Store apps regularly exceed 10s on CI
|
|
86
|
+
runners (ARM64 especially); managed launches default to a 30s discovery timeout.
|
|
87
|
+
- **No leaks**: the context manager closes the window and kills the process on exit,
|
|
88
|
+
and a timed-out discovery kills its own launcher.
|
|
89
|
+
|
|
90
|
+
---
|
|
91
|
+
|
|
92
|
+
## Quickstart
|
|
93
|
+
|
|
94
|
+
```python
|
|
95
|
+
from wintegrate import NOTEPAD, Session, SessionConfig
|
|
96
|
+
|
|
97
|
+
config = SessionConfig(
|
|
98
|
+
artifact_dir="./ci-artifacts",
|
|
99
|
+
record_video=True,
|
|
100
|
+
fps=30,
|
|
101
|
+
)
|
|
102
|
+
|
|
103
|
+
with Session(config) as session:
|
|
104
|
+
# Managed lifecycle: locale-independent discovery, single-instance safety,
|
|
105
|
+
# generous cold-start timeout, and guaranteed cleanup on exit.
|
|
106
|
+
with session.app(NOTEPAD) as app:
|
|
107
|
+
editor = app.find_text_input()
|
|
108
|
+
|
|
109
|
+
# Types hardware keystrokes and verifies line count delta & text content
|
|
110
|
+
editor.type_verified(
|
|
111
|
+
"Hello from CI\nSecond line\n",
|
|
112
|
+
expected_line_count_delta=2,
|
|
113
|
+
verify_contains="Hello from CI\nSecond line",
|
|
114
|
+
)
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
---
|
|
118
|
+
|
|
119
|
+
## Installation
|
|
120
|
+
|
|
121
|
+
```bash
|
|
122
|
+
pip install wintegrate
|
|
123
|
+
# or
|
|
124
|
+
uv add wintegrate
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
Pre-release versions (`0.1.0aN`) are not installed by default — ask for them explicitly:
|
|
128
|
+
```bash
|
|
129
|
+
pip install --pre wintegrate
|
|
130
|
+
uv add --prerelease=allow wintegrate
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
Or install from source with development dependencies:
|
|
134
|
+
```bash
|
|
135
|
+
git clone https://github.com/mangokingTW/wintegrate.git
|
|
136
|
+
cd wintegrate
|
|
137
|
+
pip install -e .[dev]
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
Windows only: the package imports on other platforms (so cross-platform tooling and
|
|
141
|
+
`env` checks work), but every Win32/UIA call raises a clear unsupported-platform error.
|
|
142
|
+
|
|
143
|
+
---
|
|
144
|
+
|
|
145
|
+
## Running Tests
|
|
146
|
+
|
|
147
|
+
Run full test suite locally:
|
|
148
|
+
```powershell
|
|
149
|
+
pytest tests/ -v -s
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
Run static code analysis & formatting check:
|
|
153
|
+
```powershell
|
|
154
|
+
ruff check src/ tests/
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
---
|
|
158
|
+
|
|
159
|
+
## License
|
|
160
|
+
|
|
161
|
+
MIT License. See [LICENSE](LICENSE) for details.
|