UI automation is a programmatic interface to external applications that needs programmatic access to the application. TX Text Control provides a very powerful API to developers who integrate the libraries into their applications. But this interface is not open to other applications from outside the application. Primarily, UI automation is used for the Windows accessibility features such as screen readers and third-party applications like speech recognition software packages.
The UI automation framework provides a streamlined way to discover UI components in an application. With version X15 of TX Text Control .NET for WPF, the UI automation framework interface is implemented and provides the following advantages:
- Enabled accessibility features
Accessibility is getting more important and applications must be compliant with government regulations.
- Automated UI testing
Applications that support the UI automation interface can be tested automatically. This can be very helpful for costly and time consuming regression testing.
UI automation provides a common interface to communicate with applications that implement this interface. The automation object is provided using the System.Windows.Automation.AutomationElement class connected with an UIElement. There are several control patterns that expose functionality which can be used from outside.
TX Text Control supports 3 patterns:
Represents a control that has an intrinsic value that does not span a range and can be represented as a string. This string may or may not be editable depending on the control and its settings.
Represents controls that contain text.
Represents objects that support synchronized input events.
How to Use the UI Automation Interface?
The following method starts an external application and returns the parent AutomationElement:
This method returns the first AutomationElement in the UI tree that supports the TextPattern (TX Text Control in this case):
The following code snippet uses the above methods to start a test application and to retrieve the TX Text Control AutomationElement. If the element supports the ValuePattern, a text is set.
The next code snippet selects the complete text in a DocumentRange:
Stay tuned for more features of TX Text Control X15.