import('gui-accessibility') provides Microsoft Active Accessibility (MSAA) and UI Automation support for the Magnolia GUI, enabling screen readers to read widget names, roles, and state.
gui := import('GUI')
acc := import('gui-accessibility')
window := gui.createWindow('Accessible App', 800, 600, {})
// Enable accessibility on the window
acc.enableAccessibility(window)
// Register widgets
acc.accRegisterButton(window, 1, 'Save', 10, 10, 80, 30)
acc.accRegisterTextField(window, 2, 'Name', 10, 50, 200, 24, '')
// Update state dynamically
acc.accSetState(window, 1, acc.STATE_SYSTEM_FOCUSED)
acc.accFocus(window, 1)
// Live announcements
acc.accAnnounce(window, 3, 'File saved successfully')
Creates an accessible node descriptor.
Gets or creates the accessibility tree for a window.
Registers a widget in the accessibility tree.
Removes a widget from the accessibility tree.
Updates the accessible name of a widget.
Updates the state flags of a widget.
Updates the value of a widget.
Updates the bounding rectangle of a widget.
Sets the accessible description.
Sets the default action label.
Notifies that a widget has gained focus.
Notifies that a widget has been selected.
Fires an accessibility event via NotifyWinEvent.
Sets up WM_GETOBJECT handling for the window so screen readers can query the accessibility tree.
Convenience functions that register common widget types with appropriate MSAA roles and states:
| Function | Role |
|---|---|
accRegisterButton(window, id, label, x, y, w, h) |
Push button |
accRegisterCheckbox(window, id, label, x, y, w, h, checked?) |
Check box |
accRegisterRadio(window, id, label, x, y, w, h, selected?) |
Radio button |
accRegisterTextField(window, id, label, x, y, w, h, value) |
Text field |
accRegisterSlider(window, id, label, x, y, w, h, value) |
Slider |
accRegisterProgressBar(window, id, label, x, y, w, h, value) |
Progress bar |
accRegisterTab(window, id, label, x, y, w, h, selected?) |
Page tab |
accRegisterListItem(window, id, label, x, y, w, h, selected?) |
List item |
accRegisterLink(window, id, label, x, y, w, h) |
Hyperlink |
accRegisterStaticText(window, id, label, x, y, w, h) |
Static text |
accRegisterGroup(window, id, label, x, y, w, h) |
Groupbox |
accRegisterTreeItem(window, id, label, x, y, w, h, expanded?) |
Tree item |
accRegisterTable(window, id, label, x, y, w, h) |
Table |
accRegisterTableCell(window, id, label, x, y, w, h) |
Table cell |
accRegisterDropdown(window, id, label, x, y, w, h, expanded?) |
Combo box |
Updates a live-region node's name and fires a change event so screen readers announce it immediately.
Dumps the accessible tree as a list of node entries for debugging.
Verifies all registered widgets have names and roles. Returns a list of issues.
Returns a human-readable name for an MSAA role constant.
Returns a human-readable description of MSAA state flags.
| Constant | Value |
|---|---|
ROLE_SYSTEM_PUSHBUTTON |
43 |
ROLE_SYSTEM_CHECKBUTTON |
44 |
ROLE_SYSTEM_RADIOBUTTON |
45 |
ROLE_SYSTEM_TEXT |
42 |
ROLE_SYSTEM_SLIDER |
51 |
ROLE_SYSTEM_PROGRESSBAR |
48 |
ROLE_SYSTEM_PAGETAB |
37 |
ROLE_SYSTEM_LISTITEM |
34 |
ROLE_SYSTEM_COMBOBOX |
46 |
ROLE_SYSTEM_TABLE |
24 |
ROLE_SYSTEM_CELL |
29 |
| Constant | Value |
|---|---|
STATE_SYSTEM_FOCUSED |
4 |
STATE_SYSTEM_SELECTED |
2 |
STATE_SYSTEM_CHECKED |
16 |
STATE_SYSTEM_PRESSED |
8 |
STATE_SYSTEM_EXPANDED |
512 |
STATE_SYSTEM_COLLAPSED |
1024 |
STATE_SYSTEM_READONLY |
64 |
STATE_SYSTEM_FOCUSABLE |
1048576 |
STATE_SYSTEM_SELECTABLE |
2097152 |
STATE_SYSTEM_HASPOPUP |
1073741824 |
| Constant | Value |
|---|---|
EVENT_OBJECT_NAMECHANGE |
32780 |
EVENT_OBJECT_STATECHANGE |
32778 |
EVENT_OBJECT_LOCATIONCHANGE |
32779 |
EVENT_OBJECT_VALUECHANGE |
32782 |
EVENT_OBJECT_FOCUS |
32773 |
EVENT_OBJECT_SELECTION |
32774 |
EVENT_OBJECT_LIVEREGIONCHANGED |
32793 |