Navigating through UITechnologyElement

At a higher level, navigating through the AX UI is a pretty basic concept. In practice, however, there are several limitations and oddities.

Picking a technology manager

There are two technology managers: "UIA" and "MSAA". Their functionality is similar, but their difference lies in how they present the UI control hierarchy.

UIA presents a much more simplified model of the hierarchy, eliminating a large number of awkward technicalities that make the hierarchy more complicated. It's also more likely to implement more sensible interpretations of the methods the interface requires. UIA doesn't, however, support old controls quite as well as new ones. For instance, UIA returns null when GetParent is called on an old UI element.

MSAA interacts with an older UI automation framework. This means it represents the UI much more directly. The hierarchy is deeper, more complicated, and harder to understand. On the other hand, MSAA support is much more general, making it work on nearly all elements of the AX UI.

It's generally good to just default to using the UIA technology manager. Only if you run into issues with that manager is it a good idea to use MSAA.

Movement

At first, the only UI elements you have access to are the ones on the stack. While it is possible to get a UI element directly, it's necessary to know its window handle. Otherwise, elements can only be accessed by traversing up and down the tree. This makes using inspect.exe essential to figure out what UI elements you can access from your targeted element.

When possible, it's a good idea to use the ordering of elements to your advantage. Other criteria like name and control type aren't necessarily supported by UIA or MSAA.

Finding controls anew

As a last resort, it is possible to get any control interface by going down from the window that contains it. AXUtils.Desktop is created for this purpose. This is about as brittle as it can get in navigation, however, so this should be avoided if at all possible.

Last edited Jul 11, 2014 at 3:21 PM by wgoodin, version 3