Understanding the UI Automation Text Object Model

This topic describes how Microsoft UI Automation client applications access the textual content of a text-based control.

Text-based controls expose textual content to UI Automation client applications through a simple text object model. Client applications have access to the text object model through the Text and TextRange control pattern interfaces, including IUIAutomationTextPattern and IUIAutomationTextRange. Client applications can use these interfaces to retrieve textual content, text attributes, and embedded objects such as tables and hyperlinks from text-based controls.

Control types that support the UI Automation text object model include the Edit and Document control types. Other control types such as ToolTip and Text might also support the text object model, but they are not required to.

Note  The UI Automation text object model does not provide a means to insert or modify text. However, some controls enable text to be inserted or modified either through the IUIAutomationValuePattern interface, or through direct keyboard input.

Control-specific Object Model

A text-based control that implements its own Document Object Model (DOM) can expose the DOM by implementing the ObjectModel control pattern. Exposing the DOM can give client applications greater access to, and control over, the content of a text-based control.

A client application can discover whether a particular text-based control implements a DOM by retrieving the control's IUIAutomationElement interface. Then, call the IUIAutomationElement::GetCurrentPropertyValue method, specifying the UIA_IsObjectModelPatternAvailablePropertyId property identifier, and a variant that receives TRUE if the control implements a DOM.

To access the DOM, call the IUIAutomationElement::GetCurrentPattern method, specifying the UIA_ObjectModelPatternId control pattern identifier and a variable that receives the IUIAutomationObjectModelPattern interface. Call the IUIAutomationObjectModelPattern::GetUnderlyingObjectModel method to retrieve the DOM interface.

Related topics

Text and TextRange Control Patterns
UI Automation Support for Textual Content
Working with Text-based Controls

 

 

Community Additions

ADD
Show:
© 2014 Microsoft