语言

AutomationElementMode 枚举

定义

包含指定在返回UI 自动化元素时要使用的引用类型的值。 这些值用于 AutomationElementMode 属性。

public enum class AutomationElementMode
public enum AutomationElementMode
type AutomationElementMode = 
Public Enum AutomationElementMode
继承
AutomationElementMode

字段

名称 值 说明
None 0

指定返回的元素没有对基础 UI 的引用,并且仅包含缓存的信息。 例如,此模式可用于检索列表框中项的名称,而无需获取对项本身的引用。

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)的完整引用。 None 指定返回的元素没有对基础 UI 的引用,并且仅包含缓存的信息。

对元素的某些操作(如 GetCurrentPropertyValue 或 SetFocus)需要完全引用;尝试对没有结果的 InvalidOperationException元素执行这些操作。

仅当需要属性时,使用 None 可以更高效,因为它可避免设置完整引用所涉及的开销。

适用于

另请参阅