The Get-UIAControlDescendants cmdlet returns all controls that are below the control that was pipelined into the cmdlet:
Start-Process calc -PassThru | Get-UIAWindow | Get-UIAControlDescendants | %{ Write-Host $_.Current.ControlType.ProgrammaticName $_.Current.Name $_.Current.AutomationId; }
This way we can get only Buttons:
Start-Process calc -PassThru | Get-UIAWindow | Get-UIAControlDescendants -ControlType Button | %{ Write-Host $_.Current.ControlType.ProgrammaticName $_.Current.Name $_.Current.AutomationId; }
Below are examples how to get a control by name (this works similarly to the Get-UIAButton cmdlet). The difference is that the Get-UIAControlDescendants cmdlet works via the FindAll method, whereas Get-UIA[ControlType] cmdlets analyze properties and apply wildcards.
Start-Process calc -PassThru | Get-UIAWindow | Get-UIAControlDescendants -Name 1 | %{ Write-Host $_.Current.ControlType.ProgrammaticName $_.Current.Name $_.Current.AutomationId; }
Start-Process calc -PassThru | Get-UIAWindow | Get-UIAControlDescendants -Name Add | %{ Write-Host $_.Current.ControlType.ProgrammaticName $_.Current.Name $_.Current.AutomationId; }

Tags: TreeScope.Ancestors

Last edited Jan 22, 2013 at 5:01 AM by xinliu, version 7

Comments

No comments yet.