Skip to content

Add ax_text: native TextPattern reads (document / selection / visible)#398

Merged
JE-Chen merged 1 commit into
devfrom
feat/ax-text-batch
Jun 24, 2026
Merged

Add ax_text: native TextPattern reads (document / selection / visible)#398
JE-Chen merged 1 commit into
devfrom
feat/ax-text-batch

Conversation

@JE-Chen

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

Copy link
Copy Markdown
Member

Why

control_get_value reads through UIA ValuePattern, which returns an empty string on multiline edits, RichEdit / document controls and web text areas — exactly the controls whose text you most want to read. UIA exposes that text through a different pattern, TextPattern. This adds three reads on top of the existing accessibility backend ABC:

  • get_control_text — whole document text (DocumentRange.GetText)
  • get_selected_text — current selection (GetSelection)
  • get_visible_text — only on-screen text (GetVisibleRanges)

Design

  • Headless core utils/ax_text/ dispatches onto the injectable accessibility.backends.get_backend() seam — the same seam control_patterns uses. Real UIA calls (IUIAutomationTextPattern, pattern id 10014) live in the Windows backend; the ABC default raises AccessibilityNotAvailableError.
  • All 5 layers wired: core → facade __all__AC_get_control_text / AC_get_selected_text / AC_get_visible_text executor commands → read-only ac_* MCP tools → Script Builder (Native UI). Executor/MCP return {"text": ...}.
  • import je_auto_control stays Qt-free (verified).

Tests

test/unit_test/headless/test_ax_text_batch.py — fake backend via the seam covers dispatch, the unsupported-backend error, the executor {text} wrapper, and 5-layer wiring. Full headless suite: 3613 passed, 16 skipped.

ValuePattern returns empty on multiline edits, RichEdit and document
controls, so control_get_value can't read exactly the controls whose
text matters most. Read through UIA TextPattern instead: full document,
current selection, and visible-only text. Dispatched via the injectable
accessibility backend seam so the core is headless-testable; real UIA
calls live in the Windows backend.
@codacy-production

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 38 complexity · 0 duplication

Metric Results
Complexity 38
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.

@JE-Chen JE-Chen merged commit 930388e into dev Jun 24, 2026
16 checks passed
@JE-Chen JE-Chen deleted the feat/ax-text-batch branch June 24, 2026 02:38
@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