UI Automation Text Attributes

This topic describes how Microsoft UI Automation exposes the format and style properties (text attributes) of textual content, and provides a list of supported text attributes.

UI Automation providers expose text attributes through the GetAttributeValue and FindAttribute methods of the TextRange control pattern. Client applications use the IUIAutomationTextRange::GetAttributeValue method to retrieve the value of a particular text attribute for a text range. Clients can use the IUIAutomationTextRange::FindAttribute method to search a text range for text that has a particular attribute. If any matching text is found, the method creates a new text range that contains the matching text.

The text attributes in the following list are supported by the TextRange control pattern. The attribute names are derived from the UI Automation text attribute identifiers. For example, the AnimationStyle attribute is identified by clients as UIA_AnimationStyleAttributeId (defined in Uiautomationclient.h) and by providers as Text_AnimationStyle_Attribute_GUID (defined in Uiautomationcoreapi.h). For more information about each supported text attribute, see Text Attribute Identifiers.

Note  Some of the attributes listed are supported starting with Windows 8. See Text Attribute Identifiers for notes regarding version support.
 

This topic contains the following sections:

Annotation Attributes

Annotation objects and annotation types are available through the following attributes.

AttributeIdentifier
AnnotationObjects UIA_AnnotationObjectsAttributeId
AnnotationTypes UIA_AnnotationTypesAttributeId

 

Font Attributes

The name, size, and weight of a font is available through the following attributes.

AttributeIdentifier
FontNameUIA_FontNameAttributeId
FontSizeUIA_FontSizeAttributeId
FontWeightUIA_FontWeightAttributeId

 

Language Attributes

Information about the language of the text is available through the following attributes.

AttributeIdentifier
CultureUIA_CultureAttributeId
TextFlowDirectionsUIA_TextFlowDirectionsAttributeId

 

Link Attribute

The following attribute provides the text range that is the target of a link in a document.

AttributeIdentifier
LinkUIA_LinkAttributeId

 

Page Margin Attributes

The bounding rectangles of a text range do not expose the coordinates of the text in the page. However, a provider can expose the page margin information using the following text attributes.

AttributeIdentifier
MarginBottomUIA_MarginBottomAttributeId
MarginLeadingUIA_MarginLeadingAttributeId
MarginTopUIA_MarginTopAttributeId
MarginTrailingUIA_MarginTrailingAttributeId

 

Text Alignment Attributes

Information about text alignment such as indentation, tab settings, and horizontal alignment is available through the following attributes.

AttributeIdentifier
HorizontalTextAlignmentUIA_HorizontalTextAlignmentAttributeId
IndentationFirstLineUIA_IndentationFirstLineAttributeId
IndentationLeadingUIA_IndentationLeadingAttributeId
IndentationTrailingUIA_IndentationTrailingAttributeId
TabsUIA_TabsAttributeId

 

Text Color Attributes

The foreground and background text colors are available through the following text attributes. Both colors are specified as a COLORREF data type.

AttributeIdentifier
BackgroundColorUIA_BackgroundColorAttributeId
ForegroundColorUIA_ForegroundColorAttributeId

 

Text Decoration Attributes

Text decorations include areas such as bullets, underlining, and animations. If text includes leading bullets or numbers, the symbol or text used for the bullet or number should be included in the text stream, if applicable.

Information about text decorations is available through the following attributes.

AttributeIdentifier
AnimationStyleUIA_AnimationStyleAttributeId
BulletStyleUIA_BulletStyleAttributeId
OutlineStylesUIA_OutlineStylesAttributeId
OverlineColorUIA_OverlineColorAttributeId
OverlineStyleUIA_OverlineStyleAttributeId
StrikethroughColorUIA_StrikethroughColorAttributeId
StrikethroughStyleUIA_StrikethroughStyleAttributeId
UnderlineColorUIA_UnderlineColorAttributeId
UnderlineStyleUIA_UnderlineStyleAttributeId

 

Text Style Attributes

Information about text styles is available though the following attributes.

AttributeIdentifier
CapStyleUIA_CapStyleAttributeId
IsHiddenUIA_IsHiddenAttributeId
IsItalicUIA_IsItalicAttributeId
IsReadOnlyUIA_IsReadOnlyAttributeId
IsSuperscriptUIA_IsSuperscriptAttributeId
IsSubscriptUIA_IsSubscriptAttributeId

 

Interaction and Selection Attributes

Information about current text selection in the range and focus state is available though the following attributes.

AttributeIdentifier
IsActiveUIA_IsActiveAttributeId
SelectionActiveEndUIA_SelectionActiveEndAttributeId
CaretPositionUIA_CaretPositionAttributeId
CaretBidiModeUIA_CaretBidiModeAttributeId

 

Related topics

Conceptual
About the UI Automation Text and TextRange Control Patterns
Text and TextRange Control Patterns
Working with Text-based Controls

 

 

Show: