To retrieve LegacyIAccessible information using UiAutomation, you can use the following steps:
- Create a UiAutomation object by calling the static method "UiAutomation.GetInstance()" on the UiAutomation class.
- Get the root element of the desktop by calling the "UiAutomation.RootElement" property on the UiAutomation object.
- Get the list of all child elements of the root element by calling the "FindAll(TreeScope.Children, Condition.TrueCondition)" method on the root element.
- 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.
- If the element supports the "LegacyIAccessible" pattern, get the "LegacyIAccessible" object by casting the result of "GetCurrentPattern(LegacyIAccessiblePattern.Pattern)" to a "LegacyIAccessiblePattern" object.
- Retrieve the information about the element using the methods of the "LegacyIAccessiblePattern" object, such as "GetChildId", "GetName", and "GetRole".