Share via


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

備註

使用者介面自動化用戶端應用程式會使用此識別碼。 使用者介面自動化提供者應該使用 中的 AutomationElementIdentifiers 對等識別碼。

您也可以從 CurrentCached 屬性擷取這個屬性。

快速鍵組合會叫用動作。 例如,CTRL+O 通常用來叫用 [開啟 檔案一般] 對話方塊。 具有快速鍵屬性集的 , AutomationElement 一律會實作 InvokePattern 類別。

屬性的傳回值的類型為 String 。 屬性的預設值是空字串。

適用於

另請參閱