如何在c#中包含AutomationElement?我要补充什么?

sas*_*aL1 3 c# automation ui-automation

我无法初始化AutomationElement。

AutomationElement element = AutomationElement.FromHandle(process.MainWindowHandle);
Run Code Online (Sandbox Code Playgroud)

它突出显示了AutomationElement,它表示的错误是http://i.stack.imgur.com/wNCvq.png

Cha*_*dan 7

UIAutomationClient.dll项目中需要引用的。该DLL文件位于C:\Program Files\Reference Assemblies\Microsoft\Framework\v3.0


Kri*_*ian 6

您需要添加相关的程序集并添加using语句才能使用该类。在这种情况下,您需要在类的顶部进行UIAutomationClient.dll汇编和using语句:using System.Windows.Automation.AutomationElement

有关更多信息,请访问MSDN页面:https : //msdn.microsoft.com/zh-cn/library/system.windows.automation.automationelement%28v=vs.110%29.aspx