Windows Automation

From IronPython Cookbook

Interacting with applications from code is often useful, both for automation and for testing purposes.

The most common way of doing this used to be with the User32 functions, which live in unmanaged code. You can access from IronPython using Dynamic Platform Invoke.

.NET 3 includes a new automation library which should make life easier: System.Windows.Automation.

Here is an example of it in action:

import clr
clr.AddReference('UIAutomationClient')
clr.AddReference('UIAutomationTypes')
from System.Windows.Automation import *

tops = AutomationElement.RootElement.FindAll(TreeScope.Children, Condition.TrueCondition)
for elem in tops:
    print elem.GetCurrentPropertyValue(AutomationElement.NameProperty)

Posted by Jim Hugunin to the IronPython Mailing List.

Back to Contents.

TOOLBOX
LANGUAGES