AXUtils and UITechnologyElementRedirect

These classes allow for behavior that the existing automation functionality provided by CUIT Extensions doesn't contain.

AXUtils

This is a static class used to create a number of extension methods for the IUITechnologyElements. These extension methods allow filters to navigate the GUI hierarchy more easily. Be aware that different technology managers have different levels of support for this (Especially Parent).

It's also important to note that almost all the AXUtils methods require AXUtils.Manager to be set. The conventional way of setting this is AXUtils.LoadManager, where the argument is the name of the technology manager (typically either "MSAA" or "UIA").

The Child methods are the more complicated methods of AXUtils (Parent simple defers to the technology manager). They all are nearly the same, with slightly differing argument lists.

public static IUITechnologyElement Child(this IUITechnologyElement element, string name, string controltype)
{
    if (Manager == null)
    {
        return null;
    }
    var enumerator = Manager.GetChildren(element, new PropertyCondition("Name", name));
    while (enumerator.MoveNext())
    {

The GetChildren method is not particularly well supported, so it's entirely reasonable for every children to be listed by the enumerator. Because of this we need to ensure that the item we return is consistent with the parameter requirements.
        if ((enumerator.Current as IUITechnologyElement).Name != null &&
            (enumerator.Current as IUITechnologyElement).Name.Contains(name) &&
            (enumerator.Current as IUITechnologyElement).ControlTypeName == controltype)
        {
            return enumerator.Current as IUITechnologyElement;
        }
    }
    return null;
}

All of the Child functions are different variations on the basic form laid out in this Child function.

UITechnologyElementRedirect

When creating a new action for the playback to execute, the extension system wants a UITechnologyElement to execute the action on. Unfortunately, most of the ways of getting technology elements give a IUITechnologyElement instead, which has a couple fields missing. The UITechnologyElementRedirect is a workaround to this problem, allowing you to pass a IUITechnologyElement and the missing data to a redirect. Because UITechnologyElementRedirect extends UITechnologyElement you can freely pass it into newly created actions.

Last edited Jul 29, 2014 at 4:25 PM by wgoodin, version 5