Skip to content

Add advanced TextPattern: find / select / read text attributes#421

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

Add advanced TextPattern: find / select / read text attributes#421
JE-Chen merged 1 commit into
devfrom
feat/ax-text-advanced-batch

Conversation

@JE-Chen

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

Copy link
Copy Markdown
Member

Why

ax_text shipped the three whole-range reads (document / selection / visible). It couldn't search for a substring, select a found range, or read text formatting attributes — needed to assert "the error word is red and bold" or to place the caret/selection at matched text before typing. This rounds TextPattern out from "dump the text" to "interrogate and manipulate" it.

  • find_control_text — whether text occurs in the control (FindText; the real content, not OCR)
  • select_control_text — find text and select its range so the next keystrokes replace it
  • control_text_attributes — the selection's {font_name, font_size, bold, italic, foreground_color}

Sixth feature of the ROUND-15 native-UIA depth lane (the v200 milestone).

Design

  • Extends the accessibility backend ABC (base.py _unsupported defaults) + real UIA in windows_backend.py (a _find_range helper over DocumentRange.FindText; GetSelection/DocumentRange + GetAttributeValue over the TextPattern attribute ids FontName=40005 / FontSize=40006 / FontWeight=40007→bold / ForegroundColor=40008 / IsItalic=40014, with module-level _attr / _read_text_attributes helpers to keep CC<10) + extends the existing utils/ax_text/ facade.
  • 5 layers wired: core → facade __all__AC_find_control_text / AC_select_control_text / AC_control_text_attributesac_* MCP tools (find/attributes read-only, select destructive) → Script Builder (Native UI). Qt-free verified.

Tests

Extended test/unit_test/headless/test_ax_text_batch.py — the fake backend gains find_text / select_text / text_attributes; covers find true/false, select, attributes, plus the updated 5-layer wiring. 17 passed with the legacy_accessible sibling. Real UIA not run in CI.

ax_text shipped whole-range reads but couldn't search a control's text,
select a found range, or read formatting. Round out TextPattern:
find_control_text searches real content (not OCR) via FindText,
select_control_text finds + selects a range so the next keystrokes
replace it, and control_text_attributes reads font/size/bold/italic/
colour. Extends the backend ABC + Windows UIA backend and the ax_text
facade.
@codacy-production

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 23 complexity · 0 duplication

Metric Results
Complexity 23
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 b27b15f into dev Jun 24, 2026
16 checks passed
@JE-Chen JE-Chen deleted the feat/ax-text-advanced-batch branch June 24, 2026 22:13
@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