axuielement
Safe Rust bindings for Apple's AXUIElement Accessibility API on macOS.
Status: v0.9 adds an optional executor-agnostic
async_apimodule forAXObservernotifications while keeping the Wave-C Swift bridge over the C Accessibility APIs and coverage across the crate's ten logical areas:AXUIElement,AXObserver,AXValue,AXTextMarker,AXAttribute,AXAction,AXNotification,AXError,SystemWide, andProcessTrust.
Quick start
use *;
Covered areas
AXUIElementcreation, attribute reads/writes, hit-testing, batch fetches, parameterized attributes, action metadata, and keyboard-event shims.AXObservercreation, add/remove notification registration, run-loop scheduling, info-dictionary callbacks, andasync_api::AXNotificationStream.AXValueround-tripping for strings, booleans, numbers,CGPoint,CGSize,CGRect,CFRange,AXError, arrays, dictionaries, and binary payloads.AXTextMarkerandAXTextMarkerRangecreation plus byte round-trips.- Generated constant modules for attributes, actions, notifications, roles, subroles, menu-item modifiers, and value constants.
SystemWideElementconvenience helpers for focused application/window/UI-element lookups.ProcessTrusthelpers for API-enabled checks and trust queries.
See COVERAGE.md for the audited SDK surface.
Raw FFI
The original raw C declarations remain available behind the raw-ffi Cargo feature:
= { = "0.9", = false }
# or keep the default `raw-ffi` feature enabled for `axuielement::ffi`
The safe API always talks to the Swift bridge. The raw-ffi feature exists for direct low-level interop and compatibility.
Permissions
Most runtime messaging requires Accessibility permission (System Settings → Privacy & Security → Accessibility). Without it, many calls return AXError::APIDisabled or AXError::CannotComplete.
Async notifications
Enable the async Cargo feature to use axuielement::async_api::AXNotificationStream, which wraps AXObserver notifications in an executor-agnostic bounded async stream.
= { = "0.9", = ["async"] }
Examples and tests
examples/01_axuielement_basic.rsexamples/02_axobserver_basic.rsexamples/03_axvalue_roundtrip.rsexamples/04_axtextmarker_roundtrip.rsexamples/05_axattribute_catalog.rsexamples/06_axaction_catalog.rsexamples/07_axnotification_catalog.rsexamples/08_axerror_catalog.rsexamples/09_system_wide_snapshot.rsexamples/10_process_trust_status.rsexamples/11_async_notification_stream.rs(requires--features async)
The test suite includes one smoke file per logical area plus the raw-FFI coverage harness.
License
Licensed under either Apache-2.0 or MIT at your option.