Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I include AutomationElement in c# ? What do I have to add?

I can't initialize the AutomationElement.

AutomationElement element = AutomationElement.FromHandle(process.MainWindowHandle);

It highlights the AutomationElement The error it says is http://i.stack.imgur.com/wNCvq.png

like image 992
sasdasdas sdsadsaL1 Avatar asked Jul 31 '15 02:07

sasdasdas sdsadsaL1


3 Answers

You need to add the relevant assembly and add a using statement to use the class. In this case you need the UIAutomationClient.dll assembly and the using statement: using System.Windows.Automation.AutomationElementat the top of your class.

For more info, visit the MSDN page: https://msdn.microsoft.com/en-us/library/system.windows.automation.automationelement%28v=vs.110%29.aspx

like image 195
Krikor Ailanjian Avatar answered Nov 14 '22 21:11

Krikor Ailanjian


In the project explorer Add references : UIAutomationClient AND UIAutomationTypes

like image 44
Dominique Mathieu Avatar answered Nov 14 '22 21:11

Dominique Mathieu


The UIAutomationClient.dll need to be referenced in the project. The DLL file is located at C:\Program Files\Reference Assemblies\Microsoft\Framework\v3.0

like image 41
Atanu Roy Avatar answered Nov 14 '22 21:11

Atanu Roy