IRawElementProviderFragment.GetRuntimeId 方法

定義

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

C#
public int[] GetRuntimeId();

傳回

Int32[]

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

範例

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

C#
/// <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 };
}

備註

實作應該會針對對應至視窗控制碼的專案傳回 null 。 其他元素應該傳回包含 AppendRuntimeId 的陣列,後面接著片段內唯一的值。

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

適用於

產品 版本
.NET Framework 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9, 10

另請參閱