Bewerken

Delen via


IRawElementProviderFragment.GetRuntimeId Method

Definition

Retrieves the runtime identifier of an element.

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

Returns

Int32[]

The unique run-time identifier of the element.

Examples

The following example code shows an implementation of this method by an element within a fragment, such as an item within a list box. The item has its own unique identifier within this instance of the fragment, and the AppendRuntimeId value ensures that the identifier returned by the method is unique in the UI Automation tree.

/// <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

Remarks

Implementations should return null for an element that corresponds to a window handle. Other elements should return an array that contains AppendRuntimeId, followed by a value that is unique within the fragment.

It is the provider's responsibility to ensure uniqueness within the fragment; for example, each item in a list must be individually numbered. The UI Automation engine ensures that the identifier is unique among all instances, by translating the AppendRuntimeId value.

Applies to

See also