MS UI Automation原来如此

MS UI Automation原来如此

最近参加了公司的一个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

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请联系我们举报,一经查实,本站将立刻删除。

发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/110846.html原文链接:https://javaforall.net

(0)
全栈程序员-站长的头像全栈程序员-站长


相关推荐

  • python一记 判断中文

    python一记 判断中文

    2021年5月12日
    98
  • 给 Pycharm 安装 pytorch

    给 Pycharm 安装 pytorch问题在之前的文章Win10通过Anaconda下载安装PyTorch中,用Anacondaprompt在base环境中安装了PyTorch,并且能在Jupyternotebook中调用。但遇到了两个问题:使用Pycharm创建新project时,envs目录下找不到pytorch的选项;在Pycharm中运行>>>importtorch报错“Couldnotfindcondaenvironment:torch”

    2022年8月27日
    3
  • redflag linux6.0 sp2桌面版,红旗Linux桌面版(Red Flag Linux)

    redflag linux6.0 sp2桌面版,红旗Linux桌面版(Red Flag Linux)第一次听说红旗Linux的“Favour”吗?现在的新名词太多,你作为第二个听说的人,一点也不落伍从09年起,针对Linux开源技术的发展特点,红旗Linux对个人版产品线做了重要调整,其中“Favour”版将尽可能把最新、最炫的DD呈现给关注开源技术的“红Fan家人”们,也希望获得更多爱好者对红旗Linux产品的关注、反馈和支持。红旗inWise操作系统V8.0是对系统软件包组件的升级和稳定性易…

    2022年8月20日
    4
  • TransactionScope应用

    TransactionScope应用.NETFramework2.0版中新增的TransactionScope单独使用确实很方便。但是在实际项目中都有自己的访问层,如何才能和自己的数据访问层结合起来使用呢?          在项目中我是这样处理数据的: /**////   ///外包业务访问类   ///   publicclassOutSourcingDAO   {       /**

    2022年7月19日
    9
  • windows/mfc程序中使用OpenGL的多重采样功能

    windows/mfc程序中使用OpenGL的多重采样功能windows程序中使用OpenGL的多重采样功能学过opengl基础的人都知道,glEnable(GL_POLYGON_SMOOTH)/glEnable(GL_LINE_SMOOTH)/glEnable(GL_POLYGON_SMOOTH)keyi欢迎使用Markdown编辑器你好!这是你第一次使用Markdown编辑器所展示的欢迎页。如果你想学习如何使用Markdown编辑器,…

    2022年5月11日
    40
  • PyCharm中如何设置切换Python Console终端的Python版本「建议收藏」

    PyCharm中如何设置切换Python Console终端的Python版本「建议收藏」在使用PyCharm的PythonConsole终端时,有时我们会需要切换终端运行的Python版本,比如下图中我的Console当前使用的版本是Python2,但是我现在想切换到Python3版本,如何做呢? 我的PyCharm版本是2018.1专业版:首先选择File——>Settings,然后进行如下操作:双击Build,Execution,Deploymen…

    2022年8月26日
    9

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

关注全栈程序员社区公众号