A window can give assistive technologies (screen readers, switch control, voice control) a tree of accessible nodes and report changes to it.
The API is the same on every platform and knows nothing of any UI engine: the app describes nodes, the platform bridge turns them into the
system's own objects. macOS (NSAccessibility) and Windows (UI Automation) are bridged; other systems keep the provider and nothing reads it
(WindowAccessibility.IsSupported is false).
The model
window.Accessibility (a WindowAccessibility) holds an IAccessibilityProvider:
| Member | Meaning |
|---|---|
RootId | the node standing for the window's content |
GetNode(id) | an AccessibleNode picture of one node, or null when it is gone |
FocusedId | the node with keyboard focus, or 0 |
HitTest(x, y) | the deepest node at a point in window pixels, or 0 |
Perform(id, action, args) | an action an assistive technology asked for |
An AccessibleNode has an app-chosen Id (positive, stable for as long as the thing exists), ParentId, Role, Name, Description,
Value, a numeric NumberValue/Minimum/Maximum, States, Actions, Bounds (window pixels, origin top left, as pointer positions
are), Children, Level, and for text fields Text with SelectionStart/SelectionEnd in UTF-16 units (equal means a caret).
Actions are Press, Focus, Increment, Decrement, SetValue, Expand, Collapse and SetSelection; only those a node lists in
Actions are ever asked for.
Everything runs on the UI thread. The provider owns the tree and answers from its current state; nodes may be fresh objects on every call.
Pull, not push
Setting Provider costs nothing. The platform builds its objects only when an assistive technology asks, and IsActive turns true (and
Activated fires) at the first request. Until then the Notify… methods return at once, so an app can call them on every change. Once active
they queue, and Flush() merges the queue and tells the system once: repeats are sent once, a structure change covers the name, value, state
and selection changes of nodes under it, only the last focus change is kept, announcements all stay in order. Nothing runs at idle: no timer,
no thread, no polling.
Notifications: NotifyFocusChanged, NotifyStructureChanged, NotifyNameChanged, NotifyValueChanged, NotifyStatesChanged,
NotifySelectionChanged, and Announce(text, priority) for speech that belongs to no node.
macOS (NSAccessibility)
The window's content view stands for the root node: it is an accessibility element with the root's role, label and children, and answers
accessibilityFocusedUIElement and accessibilityHitTest:. Every other node is an NSAccessibilityElement subclass instance made the first
time the node is asked for and kept, the same object for that node id, until the node disappears (then AXUIElementDestroyed is posted and it
is released). Its properties are read from the provider on each query, so they are never stale. Frames are converted from window pixels to
screen points with AppKit's own view, window and screen conversions.
AppKit decides which actions an element advertises from which of accessibilityPerformPress, …Increment and …Decrement its class
overrides, so there are four element classes (none, press, adjust, both) and a node that gains or loses an action gets an element of the right
class. Values: check boxes, switches and toggle buttons report 0, 1 or 2 (mixed); ranges report numbers with minimum and maximum; text
fields report their text, selection range, selected text and ranges for strings. Setting a value, focus, expansion or a selection range from
a client reaches Perform (a range is clamped to the text first, since it comes from outside).
Role mapping (the macOS column of the Core Accessibility API Mappings; names are the values of the NSAccessibility…Role and …Subrole
constants):
AccessibleRole | AX role | AX subrole |
|---|---|---|
| Button | AXButton | |
| ToggleButton | AXCheckBox | AXToggle |
| MenuButton | AXPopUpButton | |
| Link | AXLink | |
| CheckBox | AXCheckBox | |
| Switch | AXCheckBox | AXSwitch |
| RadioButton / RadioGroup | AXRadioButton / AXRadioGroup | |
| TextField (multiline: TextArea) | AXTextField (AXTextArea) | |
| SearchField | AXTextField | AXSearchField |
| ComboBox | AXComboBox | |
| ListBox / Option | AXList / AXStaticText | |
| List / ListItem | AXList / AXGroup | AXContentList / |
| Menu, MenuBar, MenuItem (and its check and radio forms) | AXMenu, AXMenuBar, AXMenuItem | |
| Slider / SpinButton | AXSlider / AXIncrementor | |
| ProgressBar / Meter | AXProgressIndicator / AXLevelIndicator | / AXMeter |
| Tab / TabList / TabPanel | AXRadioButton / AXTabGroup / AXGroup | AXTabButton / / AXTabPanel |
| Table / Row / Cell, ColumnHeader, RowHeader | AXTable / AXRow / AXCell | |
| Tree / TreeItem | AXOutline / AXRow | / AXOutlineRow |
| Toolbar, Separator, ScrollBar | AXToolbar, AXSplitter, AXScrollBar | |
| Image, Heading, StaticText | AXImage, AXHeading, AXStaticText | |
| Group, Generic, Paragraph | AXGroup | AXApplicationGroup (Group only) |
| Document, Article | AXGroup | AXDocument, AXDocumentArticle |
| Dialog, AlertDialog, Alert, Status, Tooltip | AXGroup | AXApplicationDialog, …AlertDialog, …Alert, …Status, AXUserInterfaceTooltip |
| Navigation, Main, Banner, ContentInfo, Complementary, Region, Search, Form | AXGroup | AXLandmarkNavigation, …Main, …Banner, …ContentInfo, …Complementary, …Region, …Search, …Form |
Choices that differ from the table or fill a gap in it:
- The name is exposed as
accessibilityLabel(AXDescription), notaccessibilityTitle(the table says AXTitle). Custom AppKit elements use the label and VoiceOver reads it the same; giving both would be read twice. AStaticTexthas no label: its text is its value. - The description is
accessibilityHelp. The table asks for AXCustomContent (aria-description), which is not done. AXIdentifierisoneplatform-<id>, which helps tests and automation find a node.- Notifications: focus →
AXFocusedUIElementChanged; structure →AXLayoutChanged; name →AXTitleChanged; value →AXValueChanged; text selection →AXSelectedTextChanged; a state change →AXValueChangedfor checkable roles,AXRowExpanded/AXRowCollapsedfor expandable nodes andAXSelectedChildrenChangedon the parent for selectable ones; announcements →AXAnnouncementRequestedwith the priority (polite 50, assertive 90). Notifications are posted only for nodes that already have an element: a client cannot know the others.
A Windows UI Automation adapter
The provider interface is enough for one. A UIA provider needs, per node, from AccessibleNode: IRawElementProviderSimple properties
(ControlType from the role per the UIA column of the same mapping tables, Name, HelpText, IsEnabled, HasKeyboardFocus, IsKeyboardFocusable,
BoundingRectangle in screen pixels, AutomationId from the id) and the patterns the node's Actions and role imply (Invoke for Press, Value
and RangeValue for Value/NumberValue, Toggle for Checked/Mixed, ExpandCollapse, SelectionItem, Text for fields with Text and the
selection). IRawElementProviderFragment navigation (parent, first/last child, siblings) comes from ParentId and Children; the fragment
root is the root node answering WM_GETOBJECT on the window, with ElementProviderFromPoint from HitTest and GetFocus from FocusedId.
Events map one to one: focus → UiaRaiseAutomationEvent(AutomationFocusChanged), structure →
UiaRaiseStructureChangedEvent, name/value/state → UiaRaiseAutomationPropertyChangedEvent, announcement →
UiaRaiseNotificationEvent. Lazy pull fits: UIA only calls the provider once a client has asked, and IsActive can be set from the first
WM_GETOBJECT. Two additions would help: a way for the platform to ask the app whether a node is still alive (the provider's GetNode null
already says that), and bounds in screen pixels, which the window already converts.
Testing
CocoaAccessibilityTests open a window and send the NSAccessibility messages to the content view and its elements from inside the process, so
no Accessibility permission is involved. tests/OnePlatform.AxProof is the out-of-process check: host <stop-file> opens a window with a
small tree and client <pid> reads and operates it through the AXUIElement API as a screen reader would, and prints the notifications the
system delivered. The client needs the Accessibility permission for whatever runs it (AXIsProcessTrusted), and exits with a message when it
has none. Notifications cannot be observed in-process: macOS delivers them to out-of-process observers only, so the in-process tests record
what the bridge hands to AppKit.
Windows (UI Automation)
A Win32 window answers WM_GETOBJECT for UiaRootObjectId with the provider's root node (UiaReturnRawElementProvider). Setting a provider
still costs nothing: the first request is what makes IsActive true, every other element is made the first time UI Automation navigates to
it (and is the same object for that node id until the node goes away), and events are raised only while UiaClientsAreListening says a client
listens. The COM interfaces are source-generated ([GeneratedComInterface]/[GeneratedComClass]), so the bridge is NativeAOT- and
trim-clean; the only native calls are UIAutomationCore.dll, oleaut32.dll and user32.dll.
- Threads. UI Automation calls providers on threads of its own. Each call is carried to the window's thread with a sent message
(
SendMessageTimeout, 5 s), soIAccessibilityProvideris only ever used on the UI thread; a call that cannot get there in time fails with an error HRESULT, and so does one whose provider throws. The app's loop must pump messages (anyPumpEventsdoes). - The root is the window. UI Automation merges the provider's root with the window's own element: it stays a Window and keeps the
window's title unless the root node has a
Name(the root's role and control type are not used), and the app's nodes are its children. - Coordinates.
Bounds(window pixels) become screen pixels throughClientToScreen;ElementProviderFromPointconverts the other way and asksHitTest.IsOffscreenis true for an empty rectangle or one outside the client area. - Properties: control type, Name, HelpText (the node's
Description), AutomationId (the node id), IsEnabled, IsKeyboardFocusable, HasKeyboardFocus, IsOffscreen, IsPassword, IsRequiredForForm, IsControlElement/IsContentElement (anonymous generic nodes are neither), FrameworkId (OnePlatform), landmark type and localized landmark type for the landmark roles, heading level. A localized control type is given only where the role is more specific than its control type (switch, heading, dialog, landmarks...), in English; for the rest UI Automation names the control type in the user's language. - Patterns, chosen from the role, states and actions: Invoke (
Press, when no more specific pattern applies), Toggle (check box, switch, toggle button, check menu item;Presstoggles), Value (text roles, or any node withSetValue; a password reads as empty), RangeValue (nodes with a number; small step is a hundredth and large step a tenth of the range, a write outside the range is refused), ExpandCollapse (ExpandableorExpand/Collapse), SelectionItem (radio button, tab, option, radio menu item, and selectable list items, tree items, rows and cells;SelectperformsPress, elseSetSelection, and selection is single). Disabled nodes refuse actions (UIA_E_ELEMENTNOTENABLED). The containers offer no Selection pattern, and there are no Text, Scroll, Grid or Table patterns yet. - Events from
Flush(): focus (AutomationFocusChanged), structure (ChildrenInvalidated), property changes (Name; Value or RangeValue value; for a state change every state-derived property the node has, as the batch cannot say which moved: IsEnabled, IsKeyboardFocusable, ToggleState, ExpandCollapseState, IsSelected, Value.IsReadOnly), the SelectionItemElementSelectedevent, and announcements asUiaRaiseNotificationEvent(polite speech is queued in order; assertive speech is important and replaces what is queued). - UI Automation asks a provider to focus an element before it runs a pattern on it, so a client's
Invokearrives asFocusthenPress.
tests/OnePlatform.UiaProof serves a window with a button, a check box, a text field, a slider and a list; tools/uia/client.ps1 is a
black-box UI Automation client (the framework's own UIAutomationClient) that walks it, hit-tests it, acts through the patterns and checks
the events, and tools/uia/run-guest.ps1 runs both in a Windows desktop session and saves a screenshot, aot-guest.ps1 runs the NativeAOT smoke app, and narrator-guest.ps1 runs Narrator beside the window (-Repo names the checkout and -Out the folder for logs and captures).
Gaps
No relations (labelled-by, controls), no table or outline row/column information beyond the roles, no custom content for descriptions, no text attributes or per-range bounds, no rotor or custom actions, and no AT-SPI bridge in this package (OneApp has its own AT-SPI bridge). On Windows there is no Text, Scroll, Grid, Table or Selection (container) pattern, no relations (labelled-by) and no localized strings.