AutomationElementMode 枚举
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
包含指定返回 UI 自动化元素时所使用的引用类型的值。 这些值在 AutomationElementMode 属性中使用。
public enum class AutomationElementMode
C#
public enum AutomationElementMode
type AutomationElementMode =
Public Enum 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;
' 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 可以更高效,因为它避免了设置完整引用所涉及的开销。
产品 | 版本 |
---|---|
.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 |