Skip to content

Add control_patterns: extended UIA patterns (Expand/Select/Range/Scroll)#397

Merged
JE-Chen merged 2 commits into
devfrom
feat/control-patterns-batch
Jun 24, 2026
Merged

Add control_patterns: extended UIA patterns (Expand/Select/Range/Scroll)#397
JE-Chen merged 2 commits into
devfrom
feat/control-patterns-batch

Conversation

@JE-Chen

@JE-Chen JE-Chen commented Jun 24, 2026

Copy link
Copy Markdown
Member

摘要

新增 expand_control / collapse_control / control_expand_state / select_control_item / control_range / set_control_range / scroll_control_into_view — 在既有無障礙後端 ABC 之上補上擴充 UIA 控制模式。後端原本只有 Value/Invoke/Toggle/Grid-read 四種模式,使得樹狀檢視、清單/下拉、滑桿與螢幕外列無法以原生模式驅動,只能退回脆弱的像素猜測。

新增 ExpandCollapse / SelectionItem / RangeValue / ScrollItem 物件層級動作,透過可注入的 accessibility.backends.get_backend() 接縫分派(與無障礙模組其餘部分相同接縫),因此無頭核心可在任何平台以 fake backend 單元測試;真正的 UI Automation 呼叫位於 Windows 後端。未實作某模式的後端拋出 AccessibilityNotAvailableError。Qt-free。

五層

  • 後端 ABC:accessibility/backends/base.py 加 7 個 method(預設 _unsupported);Windows 後端:真正 UIA pattern 呼叫(pattern IDs 10005/10010/10003/10017)。
  • 核心:utils/control_patterns/ — 7 個 facade 函式分派 get_backend()。
  • Facade / Executor(AC_expand_control 等 7 個)/ MCP(ac_* 動作類 destructive、讀取類 read-only,加入 a11y_control_tools)/ Script Builder(Native UI)。
  • 文件:v181 EN + Zh + toctree。更新日誌:root EN + zh-TW + zh-CN。

測試

test_control_patterns_batch.py — 注入 fake backend 驗證 expand/collapse 分派、expand_state、select、range get/set、scroll、unsupported backend 正確 raise、wiring + facade。8 passed。ruff / bandit / radon / Qt-free 全乾淨。

The accessibility backend had only Value/Invoke/Toggle/Grid-read, so treeviews,
listboxes/combos, sliders and off-screen rows had no native pattern path. Add
ExpandCollapse / SelectionItem / RangeValue / ScrollItem actions on top of the
existing backend ABC, dispatched through the injectable get_backend() seam
(headless-testable via a fake backend; real UIA calls in the Windows backend).
@codacy-production

codacy-production Bot commented Jun 24, 2026

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 55 complexity · 0 duplication

Metric Results
Complexity 55
Duplication 0

View in Codacy

NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.

The test's _FakeBackend overrode pattern methods with **kw instead of the
explicit name/role/app_name/automation_id signature, which Codacy/Pylint flags
as arguments-differ. Use the same signatures as AccessibilityBackend.
@JE-Chen JE-Chen merged commit 1111f6d into dev Jun 24, 2026
16 checks passed
@JE-Chen JE-Chen deleted the feat/control-patterns-batch branch June 24, 2026 00:37
@sonarqubecloud

Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant