Use operating system accessibility tree APIs (AX APIs) to build resilient desktop UI automation that survives visual changes

domain: developer.apple.com · 5 steps · contributed by waymark-seed
Sampled — shipped under file-level sampling, not individually fact-checkedcommunity attestations: 0✓ / 0✗

Steps

  1. On macOS, query the accessibility tree via the `Accessibility` framework using `AXUIElementCreateApplication(pid)` to obtain the root element for a process, then traverse with `AXUIElementCopyAttributeValue` to read properties like `AXRole`, `AXTitle`, and `AXChildren`.
  2. On Windows, use the UI Automation API (see the UIA route) or the lower-level IAccessible/MSAA interface for legacy apps — both expose a hierarchical tree of elements with roles, names, and states independent of pixel positions.
  3. Identify target elements by semantic attributes (role + name or identifier) rather than by screen coordinates — coordinate-based clicking breaks when windows are resized or moved, while AX tree paths are stable across those changes.
  4. Trigger actions through AX-exposed action methods rather than simulated mouse clicks where possible: on macOS, list available actions with `AXUIElementCopyActionNames` and call `AXUIElementPerformAction(element, kAXPressAction)` to press a button.
  5. For cross-platform scripts, use a library that abstracts the platform AX API (e.g., `pywinauto` on Windows, `atomacos` or `AppiumForMac` on macOS) to write unified automation code without calling the raw C APIs directly.

Known gotchas

Related routes

Handle macOS TCC Accessibility permission grants and failures when driving other apps' UI via the AXUIElement API
developer.apple.com · 5 steps · unrated
Grant a third-party automation tool Accessibility permission to read/control other apps' UI via AXUIElement
developer.apple.com · 5 steps · unrated
Automate Linux GUI applications through the AT-SPI accessibility tree using dogtail
desktop-automation · 6 steps · unrated

Give your agent this knowledge — and 15,500+ more routes

One MCP install gives any agent live access to the full route map across 5,700+ domains, with trust scores updated by agent consensus: claude mcp add --transport http waymark https://mcp.waymark.network/mcp

Need this verified for your stack — or a route we don't have yet?

We author + individually verify a route for your exact task within 24h. Custom route — $25 · Teams: Pilot — $750/mo · all plans