Skip to main content

Crate xa11y

Crate xa11y 

Source
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.
ClickOptions
Options for Mouse::click_with.
DragOptions
Options for Mouse::drag_with.
Element
A live element with lazy navigation via a provider reference.
ElementData
The raw data for a single element in an accessibility tree.
Event
An accessibility event delivered to subscribers.
InputSim
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/y are signed to support negative multi-monitor coordinates. width/height are unsigned (always non-negative).
Screenshot
A captured image: raw RGBA8 pixels plus dimensions and scale.
ScrollDelta
Direction and magnitude of a scroll event, in platform “ticks” (typically one notch of a physical scroll wheel). Positive dy scrolls content downward (i.e. moves the viewport up); positive dx scrolls right.
StateSet
Boolean state flags for an element.
Subscription
A live event subscription. Drop to unsubscribe.
SubscriptionIter
Blocking iterator over events from a Subscription.

Enums§

Anchor
Where on an element to land a pointer event.
ClickTarget
Explicit target for Mouse::click_with: either a raw point or an element to anchor against.
ElementState
Desired element state for wait_for operations.
Error
Structured error type for xa11y operations. Designed to be informative across FFI boundaries.
EventKind
The kind of accessibility event, normalized across platforms.
Key
A keyboard key.
MouseButton
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.
StateFlag
Individual state flags used in EventKind::StateChanged.
Toggled
Tri-state toggle value.

Traits§

AppExt
Extension trait that adds singleton-based constructors to App.
InputProvider
Platform backend trait for synthesised user input.
IntoPoint
A target that can be lowered to a screen Point.
ScreenshotProvider
Platform backend trait for screen capture.

Functions§

anchor_point
Compute a Point inside a Rect using the given Anchor.
input_sim
Build an InputSim backed by the platform’s native input-synthesis API (CGEvent on macOS, SendInput on Windows, XTest on X11). Returns Error::Unsupported on a Wayland-only Linux session and Error::Platform on any other platform we don’t ship a backend for.
point_for
Resolve an Element’s current bounds to a screen Point using anchor.
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§

RawPlatformData
Platform-specific raw data attached to every element.
Result
Result type alias for xa11y operations.