Expand description
xa11y — Cross-Platform Accessibility Client Library
Provides a unified API for reading and interacting with accessibility trees across desktop platforms (macOS, Windows, Linux).
§Quick Start
use xa11y::*;
let app = App::by_name("Safari").expect("App not found");
for child in app.children().unwrap() {
println!("{}: {:?}", child.role, child.name);
}
app.locator(r#"button[name="OK"]"#).press().expect("Failed to press");Modules§
- input
- Input simulation: synthesised pointer and keyboard events.
- screenshot
- Screenshot capture: pixel-level snapshots of the screen or a region.
Structs§
- App
- A running application, the entry point for accessibility queries.
- Click
Options - Options for
Mouse::click_with. - Drag
Options - Options for
Mouse::drag_with. - Element
- A live element with lazy navigation via a provider reference.
- Element
Data - The raw data for a single element in an accessibility tree.
- Event
- An accessibility event delivered to subscribers.
- Input
Sim - Synthesises OS-level pointer and keyboard events.
- Keyboard
- Keyboard operations. Obtain via
InputSim::keyboard. - Locator
- Mouse
- Pointer operations. Obtain via
InputSim::mouse. - Point
- A 2D point in screen coordinates.
- Rect
- Screen-pixel bounding rectangle (origin + size).
x/yare signed to support negative multi-monitor coordinates.width/heightare unsigned (always non-negative). - Screenshot
- A captured image: raw RGBA8 pixels plus dimensions and scale.
- Scroll
Delta - Direction and magnitude of a scroll event, in platform “ticks” (typically
one notch of a physical scroll wheel). Positive
dyscrolls content downward (i.e. moves the viewport up); positivedxscrolls right. - State
Set - Boolean state flags for an element.
- Subscription
- A live event subscription. Drop to unsubscribe.
- Subscription
Iter - Blocking iterator over events from a
Subscription.
Enums§
- Anchor
- Where on an element to land a pointer event.
- Click
Target - Explicit target for
Mouse::click_with: either a raw point or an element to anchor against. - Element
State - Desired element state for wait_for operations.
- Error
- Structured error type for xa11y operations. Designed to be informative across FFI boundaries.
- Event
Kind - The kind of accessibility event, normalized across platforms.
- Key
- A keyboard key.
- Mouse
Button - A mouse button.
- Role
- A normalized enum covering UI element types across all platforms. Derived from ARIA roles, scoped to roles commonly surfaced by real desktop applications.
- State
Flag - Individual state flags used in
EventKind::StateChanged. - Toggled
- Tri-state toggle value.
Traits§
- AppExt
- Extension trait that adds singleton-based constructors to
App. - Input
Provider - Platform backend trait for synthesised user input.
- Into
Point - A target that can be lowered to a screen
Point. - Screenshot
Provider - Platform backend trait for screen capture.
Functions§
- anchor_
point - Compute a
Pointinside aRectusing the givenAnchor. - input_
sim - Build an
InputSimbacked by the platform’s native input-synthesis API (CGEvent on macOS, SendInput on Windows, XTest on X11). ReturnsError::Unsupportedon a Wayland-only Linux session andError::Platformon any other platform we don’t ship a backend for. - point_
for - Resolve an
Element’s current bounds to a screenPointusinganchor. - screenshot
- Capture the full primary display.
- screenshot_
element - Capture the pixels under an element’s current bounds.
- screenshot_
region - Capture an explicit sub-rectangle of the screen.
Type Aliases§
- RawPlatform
Data - Platform-specific raw data attached to every element.
- Result
- Result type alias for xa11y operations.