AutomationElement.FindAll(TreeScope, Condition) Yöntem

Tanım

Belirtilen koşulu karşılayan tüm AutomationElement nesneleri döndürür.

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

Parametreler

scope
TreeScope

Aramanın kapsamını belirten değerlerin bit düzeyinde birleşimi.

condition
Condition

Eşleşecek ölçütleri içeren nesne.

Döndürülenler

AutomationElementCollection

Belirtilen koşulu karşılayan nesne koleksiyonu. Eşleşme yoksa boş bir koleksiyon döndürülür.

Örnekler

Aşağıdaki örnekte, bir penceredeki tüm etkin düğmeleri bulmak için nasıl kullanılacağı FindAll gösterilmektedir.

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

Açıklamalar

Aramanın kapsamı, yönteminin çağrıldığı öğeye göredir. Öğeler, ağaçta karşılaşıldıkları sırayla döndürülür.

Masaüstünde en üst düzey pencereleri ararken, öğesini değil Descendantsiçinde scopebelirttiğinizden Children emin olun. Masaüstünün alt ağacının tamamında yapılan bir arama binlerce öğede yinelenebilir ve yığın taşmasına yol açabilir.

İstemci uygulamanız kendi kullanıcı arabirimindeki öğeleri bulmaya çalışabilirse, tüm UI Otomasyonu çağrılarını ayrı bir iş parçacığında yapmanız gerekir.

Şunlara uygulanır

Ayrıca bkz.