共用方式為


UI 自動化屬性概觀

注意事項注意事項

這份文件適用於想要使用 System.Windows.Automation 命名空間中定義之 Managed UI Automation 類別的 .NET Framework 開發人員。如需 UI Automation 的最新資訊,請參閱 Windows Automation API:使用者介面自動化 (英文)。

UI 自動化提供者會公開 Microsoft UI Automation項目上的屬性。 這些屬性可讓 UI 自動化用戶端應用程式找到user interface (UI) (特別是控制項) 的資訊,包括靜態和動態資料。

這個主題包含下列章節。

  • 屬性識別項
  • 按類別分類屬性
  • 當地語系化
  • 屬性和事件
  • 相關主題

本節提供 Microsoft UI Automation屬性的概觀說明。 下列各主題提供更詳細的資訊:

屬性識別項

每一個屬性都是由一個編號及名稱所識別。 屬性名稱僅用於偵錯及診斷作業。 提供者使用數值 IDs 來識別傳入的屬性要求。 但是,用戶端應用程式只使用 AutomationProperty (會封裝編號及名稱) 以識別他們要擷取的屬性。

代表特定屬性的 AutomationProperty 物件,在許多類別中可做為欄位使用。 基於安全性考量,UI 自動化提供者會從 Uiautomationtypes.dll 內含的不同類別集之中取得這些物件。

下表按照內含 AutomationProperty IDs 的類別來分類屬性。

屬性的種類

用戶端取得 ID 的來源

提供者取得 ID 的來源

所有項目都有的屬性 (請參閱下表)

AutomationElement

AutomationElementIdentifiers

視窗的停駐位置

DockPattern

DockPatternIdentifiers

可展開和摺疊的項目 (Element) 狀態

ExpandCollapsePattern

ExpandCollapsePatternIdentifiers

格線中的項目 (Item) 屬性

GridItemPattern

GridItemPatternIdentifiers

格線屬性

GridPattern

GridPatternIdentifiers

具有多個檢視的項目之目前及支援的檢視

MultipleViewPattern

MultipleViewPatternIdentifiers

在某個範圍值上移動的項目 (例如滑桿) 之屬性

RangeValuePattern

RangeValuePatternIdentifiers

控制視窗捲動的屬性

ScrollPattern

ScrollPatternIdentifiers

可選擇的項目 (例如清單中的項目) 之狀態與容器

SelectionItemPattern

SelectionItemPatternIdentifiers

內含選取項目的控制項之屬性

SelectionPattern

SelectionPatternIdentifiers

表格中項目的資料行與資料列行首

TableItemPattern

TableItemPatternIdentifiers

表格的方向和資料行與資料列行首

TablePattern

TablePatternIdentifiers

切換控制項的狀態

TogglePattern

TogglePatternIdentifiers

可移動、旋轉或重新調整大小的項目之功能

TransformPattern

TransformPatternIdentifiers

具有值的項目之值以及讀取/寫入功能

ValuePattern

ValuePatternIdentifiers

視窗的功能與狀態

WindowPattern

WindowPatternIdentifiers

按類別分類屬性

下表針對可在 AutomationElementAutomationElementIdentifiers 中找到其 IDs 的屬性進行分類。 所有控制項都有這些屬性。 除了少數幾個外,其他在提供者應用程式的存留期可能是靜態的,大部分動態屬性都與控制項模式相關。

[Property Access] 資料行中,除了 GetCurrentPropertyValueGetCachedPropertyValue 以外,還列出每個屬性的任何其他存取子。 如需取得用戶端應用程式屬性的詳細資訊,請參閱用戶端的 UI 自動化屬性

注意事項注意事項

如需每一個屬性的特定資訊,請按一下 [Property Access] 資料行中的連結。

顯示特性

屬性識別項

屬性存取

BoundingRectangleProperty

BoundingRectangle

CultureProperty

N/A

HelpTextProperty

HelpText

IsOffscreenProperty

IsOffscreen

OrientationProperty

Orientation

項目型別

屬性識別項

屬性存取

ControlTypeProperty

ControlType

IsContentElementProperty

IsContentElement

IsControlElementProperty

IsControlElement

ItemTypeProperty

ItemType

LocalizedControlTypeProperty

LocalizedControlType

識別

屬性識別項

屬性存取

AutomationIdProperty

AutomationId

ClassNameProperty

ClassName

FrameworkIdProperty

FrameworkId

LabeledByProperty

LabeledBy

NameProperty

Name

ProcessIdProperty

ProcessId

RuntimeIdProperty

GetRuntimeId

NativeWindowHandleProperty

NativeWindowHandle

互動

屬性識別項

屬性存取

AcceleratorKeyProperty

AcceleratorKey

AccessKeyProperty

AccessKey

ClickablePointProperty

GetClickablePoint

HasKeyboardFocusProperty

HasKeyboardFocus

IsEnabledProperty

IsEnabled

IsKeyboardFocusableProperty

IsKeyboardFocusable

模式支援

屬性識別項

屬性存取

IsDockPatternAvailableProperty

GetSupportedPatterns

IsExpandCollapsePatternAvailableProperty

GetSupportedPatterns

IsGridItemPatternAvailableProperty

GetSupportedPatterns

IsGridPatternAvailableProperty

GetSupportedPatterns

IsInvokePatternAvailableProperty

GetSupportedPatterns

IsMultipleViewPatternAvailableProperty

GetSupportedPatterns

IsRangeValuePatternAvailableProperty

GetSupportedPatterns

IsScrollItemPatternAvailableProperty

GetSupportedPatterns

IsScrollPatternAvailableProperty

GetSupportedPatterns

IsSelectionItemPatternAvailableProperty

GetSupportedPatterns

IsSelectionPatternAvailableProperty

GetSupportedPatterns

IsTableItemPatternAvailableProperty

GetSupportedPatterns

IsTablePatternAvailableProperty

GetSupportedPatterns

IsTextPatternAvailableProperty

GetSupportedPatterns

IsTogglePatternAvailableProperty

GetSupportedPatterns

IsTransformPatternAvailableProperty

GetSupportedPatterns

IsValuePatternAvailableProperty

GetSupportedPatterns

IsWindowPatternAvailableProperty

GetSupportedPatterns

其他

屬性識別項

屬性存取

IsRequiredForFormProperty

IsRequiredForForm

IsPasswordProperty

IsPassword

ItemStatusProperty

ItemStatus

當地語系化

UI Automation提供者應該以作業系統所使用的語言來顯示下列屬性:

屬性和事件

屬性變更事件的概念即是要與 UI Automation做緊密的繫結。 如果是動態屬性,用戶端應用程式需要一個知道屬性值已變更的方法,以更新資訊快取區或根據新資料做出回應。

當 UI 變更時,提供者會引發事件。 例如,如果選取或清除核取方塊,提供者的 Toggle 模式實作就會引發屬性變更事件。 提供者可以視任何用戶端是否正在接聽事件或接聽特定事件,以選擇性地引發事件。

並非所有屬性變更都會引發事件,這完全由項目的 UI 自動化提供者實作所決定。 例如,當 SelectionProperty 變更時,清單方塊的標準 Proxy 提供者就不會引發事件。 此時,應用程式就必須接聽 ElementSelectedEvent

用戶端可以透過訂閱事件的方式以接聽事件。 訂閱事件就是建立可處理事件的委派方法,然後將方法以及會和這些方法一起處理的特定事件一起傳送至 UI Automation。 特別是針對屬性變更事件,用戶端必須實作 AutomationPropertyChangedEventHandler

請參閱

工作

根據屬性條件尋找 UI 自動化項目

從 UI 自動化提供者傳回屬性

UI 自動化提供者引發事件

概念

UI 自動化用戶端中的快取

用戶端的 UI 自動化屬性

伺服器端 UI 自動化提供者實作