AutomationElement.FindAll(TreeScope, Condition) 메서드
정의
중요
일부 정보는 릴리스되기 전에 상당 부분 수정될 수 있는 시험판 제품과 관련이 있습니다. Microsoft는 여기에 제공된 정보에 대해 어떠한 명시적이거나 묵시적인 보증도 하지 않습니다.
지정된 조건을 충족하는 모든 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
설명
검색 범위는 메서드가 호출되는 요소를 기준으로 합니다. 요소는 트리에서 발생한 순서대로 반환됩니다.
데스크톱에서 최상위 창을 검색할 ChildrenscopeDescendants때는 . 데스크톱의 전체 하위 트리를 검색하면 수천 항목을 반복하여 스택 오버플로가 발생할 수 있습니다.
클라이언트 애플리케이션이 자체 사용자 인터페이스에서 요소를 찾으려고 할 수 있는 경우 별도의 스레드에서 모든 UI 자동화 호출을 수행해야 합니다.