Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

To retrieve LegacyIAccessible information using UiAutomation, you can use the following steps:

  1. Create a UiAutomation object by calling the static method "UiAutomation.GetInstance()" on the UiAutomation class.
  2. Get the root element of the desktop by calling the "UiAutomation.RootElement" property on the UiAutomation object.
  3. Get the list of all child elements of the root element by calling the "FindAll(TreeScope.Children, Condition.TrueCondition)" method on the root element.
  4. Go through each child element in the list and check if it supports the "LegacyIAccessible" pattern by calling the "GetCurrentPattern(LegacyIAccessiblePattern.Pattern)" method on the element.
  5. If the element supports the "LegacyIAccessible" pattern, get the "LegacyIAccessible" object by casting the result of "GetCurrentPattern(LegacyIAccessiblePattern.Pattern)" to a "LegacyIAccessiblePattern" object.
  6. Retrieve the information about the element using the methods of the "LegacyIAccessiblePattern" object, such as "GetChildId", "GetName", and "GetRole".