Add ax_text: native TextPattern reads (document / selection / visible)#398
Merged
Conversation
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.
Up to standards ✅🟢 Issues
|
| Metric | Results |
|---|---|
| Complexity | 38 |
| Duplication | 0 |
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.
|
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Why
control_get_valuereads 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
utils/ax_text/dispatches onto the injectableaccessibility.backends.get_backend()seam — the same seamcontrol_patternsuses. Real UIA calls (IUIAutomationTextPattern, pattern id 10014) live in the Windows backend; the ABC default raisesAccessibilityNotAvailableError.__all__→AC_get_control_text/AC_get_selected_text/AC_get_visible_textexecutor commands → read-onlyac_*MCP tools → Script Builder (Native UI). Executor/MCP return{"text": ...}.import je_auto_controlstays 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.