MS Accessibility


Active Accessibility is technology developed by Microsoft to make the Windows platform more accessible to people with disabilities. It consists of a set of COM interfaces and methods which allow an application to expose information to third parties, making it easier to implement tools such as magnifiers and screen readers. It proves very useful also for testing utilities. Microsoft has implemented the accesibility interfaces for the standard Windows controls, and also for Office applications and components. Applications from other vendors (such as Netscape) implement Accessibility as well.

Active Accessibility is included in Windows 98, ME, 2000 and XP. It can be installed as a redistributable on Windows 95 and NT 4 (Service Pack 6) but it will only support the English locale. The redistributable is not included in Q1 due to licensing limitations, but can be downloaded for free from Microsoft's site: http://www.microsoft.com. By using the Accessibility SDK application developers can expose properties of their custom controls, making them available for scripting in Q1.

If Active Accessibility is installed, all Q1 wrappers will support the IAccessible interface, which means you can call accessibility methods and properties directly, as in the following example:

// Obtain a regular button control
var button = app.button("Push");

// The button is also an accessible object: click it
// using an IAccessible function
button.accDoDefaultAction();
		

In addition, the wnd object exposes a property called accObj which allows you to retrieve other interfaces than IAccessible. When passing OBJID_NATIVEOM as the object ID, some applications will return a reference to one of their internal (native) interfaces, which present you with a richer set of methods and properties. For example MS Office applications will return references to their own object model, which is documented in the Office SDK. Here's an example:

// Obtain the native interface for a richedit
var document = app.accObj(consts.OBJID_NATIVEOM, "RichEdit20W");

// Use it to manipulate the control. Note that document.Selection is not defined
// by either Q1 or Accessibility, it belongs to a native interface of the richedit control.
document.Selection.Font.Bold = true;
document.Selection.Text = "This was done through an ITextDocument interface";
		

NOTE: It is important to understand that an Accessibility-enabled application can expose its screen items either as full objects, or as simple elements. A full object has its own properties and methods, can be stored in a script variable and can contain other objects and simple elements. By contrast, a simple element is a virtual element which can only be accessed through its parent object. For example MS Accessibility will expose a list box control as an accessible full-object, and the list box items as simple elements. Same applies for menus and menu items, tree controls and their items and so on. Here's an example of how to access the accName property of a list box and its items:

// Print the name of a list box
Env.LogInfo(list.accName);

// Print the names of the first two list box items
Env.LogInfo(list.accName(1));
Env.LogInfo(list.accName(2));
		

In the above example there is only one script object, the one which represents the list box control. Although list box items are said to support the accName property, this property is only available through this parent object.

As you will see below, most of the IAccessible methods and properties accept an objID which specifies if the property refers to the object itself, or to one of its simple child elements. To specify the object itself, pass 0 (or consts.OBJID_SELF). For convenience this is also the default value of all object IDs, so that list.accName is equivalent to list.accName(0).

For even more ease of use, Q1 also supports passing the child name, or even a regular expression, instead of an object ID.

Here's just a quick reference over the IAccessible interface, please consult the Accessibility SDK or msdn.microsoft.com for more information:

Q1 Enhancements
accClick(objID, button, x, y, shift, ctrl, alt) Generates a real mouse click on the accessible object.
accDblClick(objID, button, x, y, shift, ctrl, alt) Generates a real mouse double click on the accessible object.
Navigation
objDest = accNavigate(navDirection, objIDStart) Moves from the current object to a different one in the same container. navDirection can be one of the consts.NAVDIR_ constants.
objChild = accChild(objID) Returns a child of the current object, as specified by objID.
count = accChildCount() Retrieves the number of children that belong to this object.
objParent = accParent() Returns an interface to the object's parent.
Object Properties
accDoDefaultAction(objID_ToRun) Performs the default action of the specified child element (or itself).
strActionDesc = accDefaultAction(objID) Returns the name of the default action of the specified child element.
strObjDesc = accDescription(objID) Returns the description of the specified child element or self.
strHelpText = accHelp(objID) Retrieves the Help property string.
strShortcut = accKeyboardShortcut(objID) Returns a string describing the keyboard shortcut for the element (for example menu item).
strObjName = accName(objID) Returns the name of the element.
idRole = accRole(objID) Returns the role of the object. Can be one of the consts.ROLE_SYSTEM_ constants.
idState = accState(objID) Retrieves the state of the object. Can be one of the consts.STATE_SYSTEM_ constants.
strValue = accValue(objID) Returns the value of the object. What the value represents depends on the object type.
Selection and Focus
accSelect(flagSelect, objID) Modifies the selection or moves the keyboard focus of the specified object. flagSelect can be one of the consts.SELFLAG_ constants.
objFocus = accFocus() Returns the ID or the interface of the object which has the focus.
objSelection = accSelection() Returns the ID or the interface of the object selected, or an enumeration containing all objects selected.
Position
accLocation(nRefLeft, nRefTop, nRefWidth, nRefHeight, objID) Retrieves the size and position of the specified object.
objHit = accHitTest(nLeft, nTop) Returns the child ID or the interface of the object present at the given coordinates.

 


© 2003 Lightweight Technologies. All rights reserved.