UIAutomtion主要使用AutomationElement类来表示UI自动化目录树中的UI自动化元素,其中包含UI自动化客户端APP应用程序用作标识符的值。
添加ui自动(向参考中添加UIAutomationClient、UIAutomationTypes、UIAutomationProvider和uiautomationclientsideproviders )。
(只有Donet 3.0以上的项目才有)
如何识别窗口。 首先启动calc.exe。
using system .诊断程序; using System.Windows.Automation;在void GetCalc () Process的Handle中使用automationelementprocess ) []p=process.getprocessesbyname ) ) calc ' ); automationelementcalcwindows=automation element.from handle (p [0].main window handle ); }
还有一个办法
using System.Windows.Automation;识别void GetCalc ()//桌面后, 桌面上窗口类型且名称为“Calculator”的automationelementrootelement=automation element.roo telent automationelementcalcwindows . Children,newandcondition ) newpropertycondition ) automent ControlType.Window ),newpropertycondition (自动元件}