AutomationElementMode 枚举

定义

包含指定返回 UI 自动化元素时所使用的引用类型的值。 这些值在 AutomationElementMode 属性中使用。These values are used in the AutomationElementMode property.

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

字段

Full 1

指定返回的元素具有对基础 UIUI 的完整引用。Specifies that returned elements have a full reference to the underlying UIUI.

None 0

指定返回的元素没有对基础 UIUI 的引用并且只包含缓存的信息。Specifies that returned elements have no reference to the underlying UIUI and contain only cached information. 例如,此模式可能用于检索列表框中的项的名称,而不获取对项本身的引用。This mode might be used, for example, to retrieve the names of items in a list box without obtaining references to the items themselves.

示例

下面的示例演示如何在上CacheRequest设置模式。The following example shows how to set the mode on a 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)user interface (UI)的完整引用。Full is the default, and specifies that returned elements contain a full reference to the underlying 用户界面 (UI)user interface (UI). None 指定返回的元素没有对基础 UI 的引用, 并且只包含缓存的信息。None specifies that the returned elements have no reference to the underlying UI, and contain only cached information.

对元素 (如GetCurrentPropertyValueSetFocus) 执行的某些操作需要完整引用; 尝试对中InvalidOperationException的无结果的元素执行这些操作。Certain operations on elements, such as GetCurrentPropertyValue or SetFocus, require a full reference; attempting to perform these on an element that has none results in an InvalidOperationException.

如果只需要属性, 则使用 "无" 会更有效, 因为这样可以避免设置完整引用所涉及的系统开销。Using None can be more efficient when only properties are needed, as it avoids the overhead involved in setting up full references.

适用于

另请参阅