How to use IUIAutomation in powershell?
See the question and my original answer on StackOverflowSystem.Windows.Automation is somewhat deprecated but:
- it works fine enough for most operations, and I'm not sure performance issues mentioned in the linked article are related to the fact it's deprecated.
- it relies on the native Windows-provided UIAutomationCore.dll assembly which contains all the new code anyway, so my guess System.Windows.Automation is indirectly using the new COM objects underneath.
- I believe it's the only API you can use from PowerShell, because you can only use COM Automation objects (not to be confused with System.Windows.Automation), ie: .NET, VB6, Scripting, etc. not pure IUnknown (not IDispatch) interfaces.
As an alternative you could use UI Automation COM-to-.NET Adapter which is a more recent version of the UIAutomationClient assembly (written by a Microsoft guy), but this is only necessary if you need Windows 8 UIA new properties and patterns, or if you observe it does work better for you.