共用方式為


UI 自動化文字屬性

本主題描述Microsoft UI 自動化如何公開文字內容的格式和樣式屬性(文字屬性),並提供支援的文字屬性清單。

使用者介面自動化提供者會透過 GetAttributeValueFindAttributeTextRange 控件模式的方法公開文字屬性。 用戶端應用程式會使用 IUIAutomationTextRange::GetAttributeValue 方法來擷取文字範圍中特定文字屬性的值。 用戶端可以使用 IUIAutomationTextRange::FindAttribute 方法來搜尋具有特定屬性之文字的文字範圍。 如果找到任何相符的文字,此方法會建立包含相符文字的新文字範圍。

TextRange 控制項模式支援下列清單中的文字屬性。 屬性名稱衍生自UI自動化文字屬性標識碼。 例如,AnimationStyle 屬性是由客戶端識別為 UIA_AnimationStyleAttributeId (定義於 Uiautomationclient.h) 和提供者識別為 Text_AnimationStyle_Attribute_GUID (定義於 Uiautomationcoreapi.h)。 如需每個支援之文字屬性的詳細資訊,請參閱 文字屬性識別碼

注意

從 Windows 8 開始,支援列出的部分屬性。 如需版本支持的相關注意事項,請參閱 文字屬性標識碼

 

本主題包含下列各節:

註釋屬性

註釋物件和批註類型可透過下列屬性取得。

屬性 標識碼
AnnotationObjects UIA_AnnotationObjectsAttributeId
AnnotationTypes UIA_AnnotationTypesAttributeId

 

字型屬性

字型的名稱、大小和粗細可透過下列屬性取得。

屬性 標識碼
FontName UIA_FontNameAttributeId
FontSize UIA_FontSizeAttributeId
FontWeight UIA_FontWeightAttributeId

 

語言屬性

文字語言的相關信息可透過下列屬性取得。

屬性 標識碼
文化 UIA_CultureAttributeId
TextFlowDirections UIA_TextFlowDirectionsAttributeId

 

下列屬性提供檔中鏈接的目標文字範圍。

屬性 標識碼
連結 UIA_LinkAttributeId

 

頁面邊界屬性

文字範圍的周框不會公開頁面中文字的座標。 不過,提供者可以使用下列文字屬性來公開頁面邊界資訊。

屬性 標識碼
MarginBottom UIA_MarginBottomAttributeId
MarginLeading UIA_MarginLeadingAttributeId
MarginTop UIA_MarginTopAttributeId
MarginTrailing UIA_MarginTrailingAttributeId

 

文字對齊屬性

文字對齊的相關信息,例如縮排、索引標籤設定和水準對齊,可透過下列屬性取得。

屬性 標識碼
HorizontalTextAlignment UIA_HorizontalTextAlignmentAttributeId
IndentationFirstLine UIA_IndentationFirstLineAttributeId
縮排前置 UIA_IndentationLeadingAttributeId
縮排 UIA_IndentationTrailingAttributeId
索引標籤 UIA_TabsAttributeId

 

文字色彩屬性

前景和背景文字色彩可透過下列文字屬性取得。 這兩種色彩都會指定為 COLORREF 數據類型。

屬性 標識碼
BackgroundColor UIA_BackgroundColorAttributeId
ForegroundColor UIA_ForegroundColorAttributeId

 

文字裝飾屬性

文字裝飾包括項目符號、底線和動畫等區域。 如果文字包含前置項目符號或數位,則適用於專案符號或數位的符號或文字應該包含在文字數據流中,如果適用的話。

文字裝飾的相關信息可透過下列屬性取得。

屬性 標識碼
AnimationStyle UIA_AnimationStyleAttributeId
BulletStyle UIA_BulletStyleAttributeId
大綱 UIA_OutlineStylesAttributeId
OverlineColor UIA_OverlineColorAttributeId
超行 UIA_OverlineStyleAttributeId
StrikethroughColor UIA_StrikethroughColorAttributeId
StrikethroughStyle UIA_StrikethroughStyleAttributeId
UnderlineColor UIA_UnderlineColorAttributeId
底線樣式 UIA_UnderlineStyleAttributeId

 

文字樣式屬性

文字樣式的相關信息可透過下列屬性取得。

屬性 標識碼
CapStyle UIA_CapStyleAttributeId
石田 UIA_IsHiddenAttributeId
IsItalic UIA_IsItalicAttributeId
IsReadOnly UIA_IsReadOnlyAttributeId
IsSuperscript UIA_IsSuperscriptAttributeId
issubscript UIA_IsSubscriptAttributeId

 

互動和選取屬性

範圍和焦點狀態中目前文字選取範圍的相關信息可透過下列屬性取得。

屬性 標識碼
IsActive UIA_IsActiveAttributeId
SelectionActiveEnd UIA_SelectionActiveEndAttributeId
CaretPosition UIA_CaretPositionAttributeId
CaretBidiMode UIA_CaretBidiModeAttributeId

 

概念

關於UI自動化文字和TextRange控制模式

Text 和 TextRange 控制項模式

使用文字型控件