語言

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。

此屬性也可從 Current 或 Cached 屬性中取得。

存取鍵是選單文字中的一個字元,或是控制項標籤中的一個字元,例如啟動附加選單功能的按鈕。 例如,字母「O」常用於從檔案選單中呼叫「檔案開啟」的共用對話框。

存取鍵值為 類型 String ,包含被註冊為該元素存取鍵的字元。 該字串的預設值為空字串。

適用於

另請參閱