AutomationElement.FindAll(TreeScope, Condition) 메서드

정의

지정된 조건에 맞는 모든 AutomationElement 개체를 반환합니다.

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

매개 변수

scope
TreeScope

검색 범위를 지정하는 값의 비트 조합입니다.

condition
Condition

대조할 조건이 들어 있는 개체입니다.

반환

지정된 조건에 맞는 개체의 컬렉션입니다. 일치 항목이 없으면 빈 컬렉션이 반환됩니다.

예제

다음 예제에서는 사용 하는 방법을 보여 줍니다 FindAll 모두 찾기 하려면 창의 단추를 사용 하도록 설정 합니다.

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

설명

검색 범위가 메서드를 호출 하는 요소를 기준으로 합니다. 요소 트리에서 발견 된 순서 대로 반환 됩니다.

바탕 화면에서 최상위 창에 대 한 검색 하는 경우 지정 해야 Childrenscope아니라 Descendants합니다. 데스크톱의 전체 하위 트리를 통해 검색 수천 개의 항목을 반복을 스택 오버플로가 발생할 수 있습니다.

클라이언트 애플리케이션이 자체 사용자 인터페이스에서 요소를 찾으려고 할 수 있는 경우 별도의 스레드에서 모든 UI 자동화 호출을 수행해야 합니다.

적용 대상

추가 정보