AutomationElementMode 列舉
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
包含指定回傳 使用者介面自動化 元素時應使用的參考類型值。 這些值會用於 AutomationElementMode 屬性中。
public enum class AutomationElementMode
public enum AutomationElementMode
type AutomationElementMode =
Public Enum AutomationElementMode
- 繼承
欄位
| 名稱 | 值 | Description |
|---|---|---|
| None | 0 | 規定回傳的元素不參考底層使用者介面,僅包含快取資訊。 例如,此模式可用於在清單框中取得項目名稱,而不必取得項目本身的參考。 |
| Full | 1 | 指定回傳的元素必須完整參考底層 UI。 |
範例
以下範例說明如何在 上 CacheRequest設定 模式。
// Set up the request.
CacheRequest cacheRequest = new CacheRequest();
// Do not get a full reference to the cached objects, only to their cached properties and patterns.
cacheRequest.AutomationElementMode = AutomationElementMode.None;
' Set up the request.
Dim cacheRequest As New CacheRequest()
' Do not get a full reference to the cached objects, only to their cached properties and patterns.
cacheRequest.AutomationElementMode = AutomationElementMode.None
備註
Full(完整)是預設,並指定回傳的元素包含對底層使用者介面(UI)的完整參考。 沒有任何一項會指定回傳的元素不參考底層 UI,且僅包含快取資訊。
某些元素上的運算,如 GetCurrentPropertyValue 或 SetFocus,需要完整參照;嘗試對沒有 或 的元素執行這些操作,會導致 InvalidOperationException。
當只需要屬性時,使用 None 會更有效率,因為它避免了建立完整參考時的額外負擔。