AutomationElement.FindAll(TreeScope, Condition) Methode

Definitie

Retourneert alle AutomationElement objecten die voldoen aan de opgegeven voorwaarde.

public:
 System::Windows::Automation::AutomationElementCollection ^ FindAll(System::Windows::Automation::TreeScope scope, System::Windows::Automation::Condition ^ condition);
public System.Windows.Automation.AutomationElementCollection FindAll(System.Windows.Automation.TreeScope scope, System.Windows.Automation.Condition condition);
member this.FindAll : System.Windows.Automation.TreeScope * System.Windows.Automation.Condition -> System.Windows.Automation.AutomationElementCollection
Public Function FindAll (scope As TreeScope, condition As Condition) As AutomationElementCollection

Parameters

scope
TreeScope

Een bitsgewijze combinatie van waarden waarmee het bereik van de zoekopdracht wordt opgegeven.

condition
Condition

Het object met de criteria die moeten worden vergeleken.

Retouren

Een verzameling objecten die voldoet aan de opgegeven voorwaarde. Als er geen overeenkomsten zijn, wordt een lege verzameling geretourneerd.

Voorbeelden

In het volgende voorbeeld ziet u hoe FindAll u alle ingeschakelde knoppen in een venster kunt vinden.

/// <summary>
/// Finds all enabled buttons in the specified window element.
/// </summary>
/// <param name="elementWindowElement">An application or dialog window.</param>
/// <returns>A collection of elements that meet the conditions.</returns>
AutomationElementCollection FindByMultipleConditions(
    AutomationElement elementWindowElement)
{
    if (elementWindowElement == null)
    {
        throw new ArgumentException();
    }
    Condition conditions = new AndCondition(
      new PropertyCondition(AutomationElement.IsEnabledProperty, true),
      new PropertyCondition(AutomationElement.ControlTypeProperty, 
          ControlType.Button)
      );

    // Find all children that match the specified conditions.
    AutomationElementCollection elementCollection = 
        elementWindowElement.FindAll(TreeScope.Children, conditions);
    return elementCollection;
}
''' <summary>
''' Finds all enabled buttons in the specified window element.
''' </summary>
''' <param name="elementWindowElement">An application or dialog window.</param>
''' <returns>A collection of elements that meet the conditions.</returns>
Function FindByMultipleConditions(ByVal elementWindowElement As AutomationElement) As AutomationElementCollection
    If elementWindowElement Is Nothing Then
        Throw New ArgumentException()
    End If
    Dim conditions As New AndCondition(New PropertyCondition(AutomationElement.IsEnabledProperty, True), New PropertyCondition(AutomationElement.ControlTypeProperty, ControlType.Button))

    ' Find all children that match the specified conditions.
    Dim elementCollection As AutomationElementCollection = elementWindowElement.FindAll(TreeScope.Children, conditions)
    Return elementCollection

End Function 'FindByMultipleConditions

Opmerkingen

Het bereik van de zoekopdracht is relatief ten opzichte van het element waarop de methode wordt aangeroepen. Elementen worden geretourneerd in de volgorde waarin ze in de structuur zijn aangetroffen.

Zorg ervoor dat Childrenscopeu bij het zoeken naar vensters op het hoogste niveau op het bureaublad, niet Descendants. Een zoekopdracht door de hele substructuur van het bureaublad kan duizenden items herhalen en leiden tot een stack-overloop.

Als uw clienttoepassing mogelijk elementen in een eigen gebruikersinterface probeert te vinden, moet u alle UI Automation aanroepen uitvoeren op een afzonderlijke thread.

Van toepassing op

Zie ook