我怎样才能赋予其HWND一个Visual Basic控件的名称? [英] How can I get the name of a Visual Basic control given its HWND?

查看:108
本文介绍了我怎样才能赋予其HWND一个Visual Basic控件的名称?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我工作的一个小宏记录/回放工具,它可以自动完成一些非常古老的Visual Basic 6的GUI,我们有。要做到这一点,我被他们的名字识别控件( name的值控制财产,那是)。

I'm working on a little macro record/replay tool which can automate a few very old Visual Basic 6 GUIs we have. To do so, I'm identifying the controls by their name (the value of the name property of a control, that is).

这个工具的一部分需要确定给予其HWND控件的名称。对于使用VB.NET这所成新的Visual Basic应用程序,我可以使用 WM_GETCONTROLNAME 窗口消息。这工作得很好。

One part of this tool needs to determine the name of a control given its HWND. For newer Visual Basic applications which were done using VB.NET, I can use the WM_GETCONTROLNAME window message. This works nicely.

不过,此消息不是由旧版Windows的理解。有没有什么办法来为Visual Basic 6的应用程序的控制做到这一点?不需要在GUI的过程是一个解决办法是preferrable,但如果我有一个解决方案,只能在GUI程序里面那么这将是可以接受的,以及(因为我可以做注射我自己)。

However, this message is not understood by older windows. Is there any way to do this for controls of Visual Basic 6 applications? A solution which does not require being in the process of the GUI would be preferrable, but if I had a solution which only works inside the GUI process then that would be acceptable as well (since I can do the injection myself).

更新:的一件事,我只是尝试,这种温和的成功:我用的 AccessibleObjectFromWindow 来检查的其中显示给定的HWND对象的IAccessible 接口。如果我得到一个实现(似乎很多[呢?] Visual Basic控件实现此接口),我使用的 accName 财产读出了访问名。有时,这确实产生有益的字符串,但通常它没有。

UPDATE: One thing I just tried, this moderate success: I used the AccessibleObjectFromWindow to check for implementations of the IAccessible interface of the object which shows the given HWND. In case I get an implementation (it seems that many [all?] Visual Basic controls implement this interface), I use the accName property to read out the "accessible name". Sometimes this does yield a useful string, but usually it doesn't.

推荐答案

您可以修改VB6应用程序?如果是在每个窗体加载事件,你可以遍历me.controls并使用 SetProp(ctrl.hwnd,MYNAME:&放大器; ctrl.name,0) API添加名称窗口自身的属性列表,然后在其他应用程序,你可以 EnumProps(ctrl_HWND)寻找一个与开始MYNAME:并解析出的价值。

Can you modify the vb6 apps? if so in each form load event you could iterate me.controls and use the SetProp(ctrl.hwnd, "MYNAME:" & ctrl.name, 0) api to add the name to the window's own property list, then in your other app you can EnumProps(ctrl_HWND) looking for the one that begins with MYNAME: and parse out the value.

这篇关于我怎样才能赋予其HWND一个Visual Basic控件的名称?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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