如何在Delphi 2009中使用MS UI Automation [英] How to use MS UI Automation in Delphi 2009

查看:694
本文介绍了如何在Delphi 2009中使用MS UI Automation的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个C#应用程序,它使用Microsoft UI Automation功能, G。一个电话,如 AutomationElement.RootElement.FindFirst(...)



现在我需要做同样的事情(使用MS UI自动化)在德尔福2009年。



我如何



a)声明我的Delphi代码使用MS UI Automation库和
b)调用类似 AutomationElement.RootElement.FindFirst(...)





有几个教程(教程1 教程2 ),说明如何打包自己的。 NET代码,以便它可以与Delphi一起使用,但在我的情况下,我需要在Delphi中使用预先打包(已经安装)程序集。



更新1



现在,我可以在一台机器上访问 AutomationElement.RootElemeent 不能在另一个工作。



我如何才能找到原因,为什么在第二台机器上尝试执行 uiAutomation:= CoCUIAutomation.Create; 失败?

解决方案

如在注释中所述,您必须将UI Automation类型库(COM Object)导入到项目中,可以使用导入组件向导(组件 - >导入组件) Delphi 2010。



Microsoft保持COM对象的界面非常接近.NET对应,所以如果您已经熟悉该应用程序,则不应该有太多麻烦来使用它。 NET自动化库。


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?

解决方案

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.

这篇关于如何在Delphi 2009中使用MS UI Automation的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆