There are six event indicating that the structure of Automation tree has been changed. These six events can be chosed as parameters of the Register-UIAStructureChangedEvent cmdlet:
Register-UIAStructureChangedEvent -ChildAdded -ChildRemoved -ChildrenInvalidated -ChildrenBulkAdded -ChildrenBulkRemoved -ChildrenReordered
In the following sample, we register a StructureChangedEvent, after that (no code provided) we perform manual or programmatic actions with GUI, and, finally, obtain the results list.
$global:annals = New-Object System.Collections.ArrayList;
Start-Process calc -PassThru | Get-UIAWindow | Register-UIAStructureChangedEvent -ChildrenBulkAdded -ChildAdded -ChildRemoved -ChildrenReordered -EventAction { param($src, $e) $global:annals.Add($src.Current.Name); $global:annals.Add($e.StructureChangeType); };

# perform manual or programmatic actions like show/hide worksheets or change mode

# display which event have been caught

Last edited Jan 21, 2013 at 8:15 PM by xinliu, version 1


No comments yet.