作者:VB.NET开发
项目:System.Windows.Automatio
'''--------------------------------------------------------------------
''' <summary>
''' Finds all automation elements that satisfy
''' the specified condition(s).
''' </summary>
''' <param name="targetApp">
''' The automation element from which to start searching.
''' </param>
''' <returns>
''' A collection of automation elements satisfying
''' the specified condition(s).
''' </returns>
'''--------------------------------------------------------------------
Private Function FindAutomationElement( _
ByVal targetApp As AutomationElement) As AutomationElementCollection
If targetApp Is Nothing Then
Throw New ArgumentException("Root element cannot be null.")
End If
Dim conditionLeafNode As New PropertyCondition( _
ExpandCollapsePattern.ExpandCollapseStateProperty, _
ExpandCollapseState.LeafNode)
Return targetApp.FindAll(TreeScope.Descendants, conditionLeafNode)
End Function 'FindAutomationElement