AutomationElementMode 枚举

定义

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

C#
public enum AutomationElementMode
继承
AutomationElementMode

字段

名称 说明
Full 1

指定返回的元素具有对基础 UI 的完全引用。

None 0

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

示例

以下示例演示如何在 上 CacheRequest设置模式。

C#
// 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;

注解

Full 是默认值,指定返回的元素包含对基础用户界面 (UI) 的完整引用。 None 指定返回的元素没有对基础 UI 的引用,并且仅包含缓存的信息。

对元素(如 GetCurrentPropertyValueSetFocus)的某些操作需要完全引用;尝试对没有 元素执行这些操作会导致 InvalidOperationException

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

适用于

产品 版本
.NET Framework 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9

另请参阅