获取 ActiveX 对象属性
简而言之:我有一个包含按钮的 ActiveX 控件的 VB6 表单,我想创建可以使用 C# 单击此按钮的自动工具。 我尝试使用反射来解决此问题,但无法访问该表单。 我建议的总体方向是使用窗口 API 来访问表单,但这似乎是非常“昂贵”的解决方案。
有谁熟悉这个主题吗? 谢谢
In short: I have a VB6 form with ActiveX control that contains buttons, and I would like to create automatic tool that can click this buttons using C#.
I tried to use reflection for this issue, but I cannot access the form.
The general direction I was suggested was to use window API to access the form, but it seem very "expensive" solution.
Does anyone familiar with this subject?
Thank you
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您可以使用 .net 中的 AutomationElement 吗?
要测试这一点:
下载UiSpy。 zip 链接取自此问题
打开表单,激活悬停模式。如果您“看到”该按钮,那么应该很容易使用] AutomationElement 实际向其发送点击。
Can you use AutomationElement from .net?
To test this:
download UiSpy.zip link taken from this question
Get the form open, activate the hover mode. If you "see" the button it should be easy to use ] AutomationElement to actually send a click to it.
发送/挂钩窗口消息(例如发送WM_MOUSEDOWN或WM_MOUSEMOVE)怎么样?简短/简化的示例可以在此处找到。
How about sending/hooking window messages (e.g. sending WM_MOUSEDOWN or WM_MOUSEMOVE)? Short/simplified example can be found here.
如果您的目标是自动化 UI 测试,我建议您使用 SmartBear Software 的 TestComplete,它可以直接访问您的 VB6 表单、控件和属性。他们基本上挂接到进程并访问“Forms”对象和“Screen”对象以访问加载的表单。
If your goal is to automate the UI for testing, I would suggest TestComplete from SmartBear Software which can directly access your VB6 forms, controls and properties. They're basically hooking into the process and accessing the "Forms" object and "Screen" object to get access to the loaded forms.