最近参加了公司的一个program competition,做个小工具。其中涉及到一个盲点。 需求是:在代码中访问另一个program的进程,获取它的窗口句柄,并在它的窗口上对某一个控件进行鼠标点击操作以执行相应的命令。google来baidu去,终于有思路了:原来需要用到MS的UI automation library。MS提供了面向c/c++的API,也提供了面向managed code的API。
Extract some overview words from below MS msdn article:
Microsoft UI Automation is an accessibility framework that enables Microsoft Windows applications to provide and consume programmatic information about user interfaces (UIs). It provides programmatic access to most UI elements on the desktop. It enables assistive technology products, such as screen readers, to provide information about the UI to end users and to manipulate the UI by means other than standard input. UI Automation also allows automated test scripts to interact with the UI.
详细背景信息参见:http://msdn.microsoft.com/zh-cn/library/ms726294%28en-us,VS.85%29.aspx
就我目前体会到的,主要有这么几点:
1. 通过这个库,我们可以做两件事情:
The Microsoft UI Automation for Microsoft Win32 API enables assistive technology applications and automated testing tools to interact with user interface (UI) controls.
The API is in two parts, that are used independently by UI Automation providers and by UI Automation client applications. The provider API enables developers of Win32 custom control and other control frameworks to expose those controls to UI Automation and make them visible to client applications. The client API enables applications to interact with controls.
2. About Spy++ and UI Spy
通过这两个工具,我们可以获取到任何一个窗口的详细UI信息,具体到一个控件的tab顺序都可以拿到。
3. 读了几个例子:
自动化测试工具的原理:http://www.cnblogs.com/Thomson-Blog/articles/1295729.html:
Major Tom 的 GUI 控件:http://blog.moneypa.com/post/Major-Tom-e79a84-GUI-e68ea7e4bbb6.aspx
Microsoft UI 自动化库:http://msdn.microsoft.com/zh-cn/magazine/cc163288.aspx
转载于:https://www.cnblogs.com/taoxu0903/archive/2009/11/17/1604989.html
发布者:全栈程序员-用户IM,转载请注明出处:https://javaforall.cn/110846.html原文链接:https://javaforall.cn
【正版授权,激活自己账号】: Jetbrains全家桶Ide使用,1年售后保障,每天仅需1毛
【官方授权 正版激活】: 官方授权 正版激活 支持Jetbrains家族下所有IDE 使用个人JB账号...