AutomationElement.AcceleratorKeyProperty 字段

定义

标识 AcceleratorKey 属性。

public: static initonly System::Windows::Automation::AutomationProperty ^ AcceleratorKeyProperty;
public static readonly System.Windows.Automation.AutomationProperty AcceleratorKeyProperty;
 staticval mutable AcceleratorKeyProperty : System.Windows.Automation.AutomationProperty
Public Shared ReadOnly AcceleratorKeyProperty As AutomationProperty 

字段值

示例

以下示例检索属性的当前值。 如果元素不提供默认值,则返回默认值。

string acceleratorKey = 
    autoElement.GetCurrentPropertyValue(AutomationElement.AcceleratorKeyProperty) as string;
Dim acceleratorKey As String = _
    CStr(autoElement.GetCurrentPropertyValue(AutomationElement.AcceleratorKeyProperty))

下面的示例检索属性的当前值,但指定如果元素本身不提供属性的值, NotSupported 则返回而不是默认值。

string acceleratorKeyString;
object acceleratorKeyNoDefault =
    autoElement.GetCurrentPropertyValue(AutomationElement.AcceleratorKeyProperty, true);
if (acceleratorKeyNoDefault == AutomationElement.NotSupported)
{
    // TODO Handle the case where you do not wish to proceed using the default value.
}
else
{
    acceleratorKeyString = acceleratorKeyNoDefault as string;
}
Dim acceleratorKeyString As String
Dim acceleratorKeyNoDefault As Object = autoElement.GetCurrentPropertyValue(AutomationElement.AcceleratorKeyProperty, True)
If acceleratorKeyNoDefault Is AutomationElement.NotSupported Then
    ' TODO Handle the case where you do not wish to proceed using the default value.
Else
    acceleratorKeyString = CStr(acceleratorKeyNoDefault)
End If

注解

此标识符由UI 自动化客户端应用程序使用。 UI 自动化提供程序应使用 AutomationElementIdentifiers 中的等效标识符。

也可以从 CurrentCached 属性中检索此属性。

快捷键组合调用操作。 例如,Ctrl+O 通常用于调用 “打开 文件通用”对话框。 具有快捷键属性集的一个 AutomationElement 始终实现 InvokePattern 类。

属性的返回值为类型 String。 属性的默认值为空字符串。

适用于

另请参阅