語言

IRawElementProviderFragment.GetRuntimeId 方法

定義

取得元素的執行時識別碼。

public:
 cli::array <int> ^ GetRuntimeId();
public int[] GetRuntimeId();
abstract member GetRuntimeId : unit -> int[]
Public Function GetRuntimeId () As Integer()

傳回

Int32[]

該元素的唯一執行時識別碼。

範例

以下範例程式碼展示了此方法由片段中的元素實作,例如清單框中的項目。 該項目在此片段實例中擁有自己的唯一識別碼,AppendRuntimeId 值確保該方法回傳的識別碼在使用者介面自動化樹中是唯一的。

/// <summary>
/// Gets the runtime identifier of the UI Automation element.
/// </summary>
/// <remarks>
/// myID is a unique identifier for the item within this instance of the list.
/// </remarks>
public int[] GetRuntimeId()
{
    return new int[] { AutomationInteropProvider.AppendRuntimeId, myID };
}
''' <summary>
''' Gets the runtime identifier of the UI Automation element.
''' </summary>
''' <remarks>
''' myID is a unique identifier for the item within this instance of the list.
''' </remarks>
Public Function GetRuntimeId() As Integer() _
    Implements IRawElementProviderFragment.GetRuntimeId

    Return New Integer() {AutomationInteropProvider.AppendRuntimeId, myID}

End Function 'GetRuntimeId

備註

實作時應該回傳 null 一個對應視窗handle的元素。 其他元素則應回傳包含 AppendRuntimeId的陣列,後接著一個在片段中唯一的值。

提供者有責任確保片段內的唯一性;例如,清單中的每個項目必須個別編號。 使用者介面自動化引擎透過轉換 AppendRuntimeId 值,確保識別碼在所有實例中是唯一的。

適用於

另請參閱