IRawElementProviderFragment.GetRuntimeId 方法

定義

擷取項目的執行階段識別項。

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

傳回

Int32[]

項目的唯一執行階段識別項。

範例

下列範例程式碼示範片段內的專案實作此方法,例如清單方塊中的專案。 專案在此片段實例內有自己的唯一識別碼,而且 AppendRuntimeId 值可確保 方法所傳回的識別碼在 UI 自動化樹狀結構中是唯一的。

/// <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 。 其他元素應該傳回包含 AppendRuntimeId 的陣列,後面接著片段內唯一的值。

提供者必須負責確保片段內的唯一性;例如,清單中每個專案都必須個別編號。 使用者介面自動化引擎藉由轉譯 AppendRuntimeId 值,確保識別碼在所有實例之間都是唯一的。

適用於

另請參閱