How to use MS UI Automation in Delphi 2009

不问归期 提交于 2019-11-27 07:26:38

问题


I have a C# application, which uses Microsoft UI Automation functionality, e. g. a call like AutomationElement.RootElement.FindFirst(...).

Now I need to do the same thing (use MS UI Automation) in Delphi 2009.

How can I

a) declare that my Delphi code uses MS UI Automation library and b) make calls like AutomationElement.RootElement.FindFirst(...)

?

There are several tutorials (tutorial 1, tutorial 2) explaining how to package one's own .NET code so that it can be used with Delphi, but in my case I need to use "pre-packaged" (already installed) assembly in Delphi.

Update 1

Now I can get access to AutomationElement.RootElemeent on one machine, but it doesn't work on another.

How can I find out the reason, why the attempt to execute uiAutomation := CoCUIAutomation.Create; fails on the second machine?


回答1:


As stated in the comments you have to import the UI Automation type library (COM Object) into your project, this can be done with the "Import Component" wizard (Component -> Import Component) in Delphi 2010.

Microsoft kept the COM Object's interface really close to it's .NET counterpart so you shouldn't have much trouble to use it if you are already familiar with the .NET automation library.



来源:https://stackoverflow.com/questions/12894215/how-to-use-ms-ui-automation-in-delphi-2009

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!