Bearbeiten

Freigeben über


Automation.Compare Method

Definition

Compares the specified parameters to determine whether they refer to the same user interface (UI) element.

Overloads

Compare(Int32[], Int32[])

Compares two integer arrays containing run-time identifiers (IDs) to determine whether their content is the same.

Compare(AutomationElement, AutomationElement)

Compares two UI Automation elements, returning true if both refer to the same UI element.

Compare(Int32[], Int32[])

Compares two integer arrays containing run-time identifiers (IDs) to determine whether their content is the same.

public:
 static bool Compare(cli::array <int> ^ runtimeId1, cli::array <int> ^ runtimeId2);
public static bool Compare (int[] runtimeId1, int[] runtimeId2);
static member Compare : int[] * int[] -> bool
Public Shared Function Compare (runtimeId1 As Integer(), runtimeId2 As Integer()) As Boolean

Parameters

runtimeId1
Int32[]

The first run-time ID to compare.

runtimeId2
Int32[]

The second run-time ID to compare.

Returns

true if the compared run-time IDs refer to the same user interface (UI) element; otherwise false.

Examples

The following example function determines whether a run-time ID is in a list of run-time IDs.

private int RuntimeIdListed(int[] runtimeId, ArrayList runtimeIds)
{
    for (int x = 0; x < runtimeIds.Count; x++)
    {
        int[] listedId = (int[])runtimeIds[x];
        if (Automation.Compare(listedId, runtimeId))
        {
            return x;
        }
    }
    return -1;
}
Private Function RuntimeIdListed(ByVal runtimeId() As Integer, ByVal runtimeIds As ArrayList) As Integer 
    Dim x As Integer
    For x = 0 To runtimeIds.Count - 1
        Dim listedId As Integer() = CType(runtimeIds(x), Integer())
        If Automation.Compare(listedId, runtimeId) Then
            Return x
        End If
    Next x
    Return - 1

End Function 'RuntimeIdListed

Remarks

If either of the arguments is a null reference (Nothing in Visual Basic), Compare throws an ArgumentNullException exception.

See also

Applies to

Compare(AutomationElement, AutomationElement)

Compares two UI Automation elements, returning true if both refer to the same UI element.

public:
 static bool Compare(System::Windows::Automation::AutomationElement ^ el1, System::Windows::Automation::AutomationElement ^ el2);
public static bool Compare (System.Windows.Automation.AutomationElement el1, System.Windows.Automation.AutomationElement el2);
static member Compare : System.Windows.Automation.AutomationElement * System.Windows.Automation.AutomationElement -> bool
Public Shared Function Compare (el1 As AutomationElement, el2 As AutomationElement) As Boolean

Parameters

el1
AutomationElement

The first UI Automation element to compare.

el2
AutomationElement

The second UI Automation element to compare.

Returns

true if the run time identifiers of the UI elements are the same; otherwise false.

Remarks

If either of the arguments is a null reference (Nothing in Visual Basic), Compare throws an ArgumentNullException exception.

This method is equivalent to the equality operator for AutomationElement objects.

See also

Applies to