AutomationElement.AccessKeyProperty 欄位

定義

識別 AccessKey 屬性。

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

欄位值

範例

下列範例會擷取 屬性的目前值。 如果專案未提供預設值,則會傳回預設值。

string accessKey =
    autoElement.GetCurrentPropertyValue(AutomationElement.AccessKeyProperty) as string;
Dim accessKey As String = _
    CStr(autoElement.GetCurrentPropertyValue(AutomationElement.AccessKeyProperty))

下列範例會擷取屬性的目前值,但指定如果專案本身未提供屬性的值, NotSupported 則會傳回 而不是預設值。

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

備註

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

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

便捷鍵是功能表、功能表項目或控制項標籤文字中的字元,例如啟動附加功能表函式的按鈕。 例如,字母 「O」 通常用來從 [檔案] 功能表叫用 [檔案開啟一般] 對話方塊。

便捷鍵值的類型 String 為 ,且包含註冊為元素存取金鑰的字元。 字串的預設值是空字串。

適用於

另請參閱