从脚本驱动 Windows GUI 程序 [英] Driving a Windows GUI program from a script

查看:11
本文介绍了从脚本驱动 Windows GUI 程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我必须使用 Windows 模拟包来执行重复性任务,每次都有略微不同的选项.

I have to use a Windows simulation package to perform a repetitive task with slightly different options each time.

由于我讨厌重复点击,基于懒惰和人类引入的错误数量,我想自动驱动这个程序.有问题的程序不支持脚本,没有 API,没有 COM、nada、nyet、nravin.据我所知,自动驱动该程序的唯一方法是模仿人类(即键盘和鼠标宏).

Since I hate repetitive clicking, on grounds of both laziness and the amount of errors that a human introduces, I would like to drive this program automatically. The program in question doesn't support scripting, there is no API, no COM, nada, nyet, nravin. As far as I can tell, the only way to drive this program automatically is to imitate a human (i.e. keyboard and mouse macros.)

我知道 AutoHotKey,但我认为它不能满足我的要求.(或者它可能会做我想做的,但它的脚本语言很糟糕.)

I am aware of AutoHotKey but I don't think it does what I want. (Or it might do what I want, but its scripting language is horrible.)

要求是:

  • 必须允许操作之间的时间延迟,或事件检测以触发操作.

  • Must allow time delays between actions, or event detection to trigger actions.

模拟可能需要长达 10 分钟才能运行,因此 GUI 驱动程序必须等到模拟完成后才能开始新的模拟.

The simulations can take up to ten minutes to run, so the GUI driver would have to wait until the simulation finishes before starting a new one.

执行此操作的一种方法是等待十分钟并希望模拟已完成.另一种方法是使其成为事件驱动的,即观察模拟运行..."对话框消失并被模拟完成"对话框取代.

One way to do this would be to just wait ten minutes and hope that the simulation has finished. An alternative way is to make it event-driven, i.e. watch for the "Simulation running..." dialog to disappear and be replaced by a "Simulation complete" dialog.

必须允许组合复杂的键盘输入.

Must allow composition of complex keyboard input.

每次模拟运行所需的某些键盘输入都不同.例如,模拟描述可能采用 [Project name][Scenario name][Option 1][Option 2]... 格式,并且必须为每个模拟输入.

Some of the keyboard input required is different for each simulation run. For example the simulation description might take the format [Project name][Scenario name][Option 1][Option 2]... and this would have to be entered for each simulation.

我知道 AutoHotKey 允许基本级别的输入自定义,但我对文档的随意阅读使脚本语言看起来像是某种可怕的恐怖.

I am aware that AutoHotKey allows a basic level of input customisation, but my casual reading of the documentation makes the scripting language look like some kind of eldritch horror.

这是为了工作,所以任何解决方案都必须免费用于商业用途.

This is for work, so any solution must be free for commercial use.

我会接受符合上述标准的任何解决方案,但我强烈偏爱我可以从 Python 驱动的东西.但是,我也会接受自动化的 GUI 测试工具,我可以自定义这些工具来做我想做的事——可能是一个 Win32 GUI 等价于 Selenium 的浏览器?- 键盘宏记录器将生成自定义输出,或任何其他有效的东西.

I will accept any solution that fits the criteria above, but I have a strong preference for something I can drive from Python. However I would also accept automated GUI-testing tools that I could customise to do what I want - possibly a Win32 GUI equivalent of Selenium for browsers? - keyboard macro recorders that will generate custom output, or anything else that works.

推荐答案

再看看 Autohotkey,从你的要求来看它似乎适合这项工作.

Give Autohotkey another look, from you requirements it seems fit for the job.

或者检查来自 Microsoft 的 UI 自动化:http://msdn.microsoft.com/en-us/library/ms747327.aspx 和白色:http://white.codeplex.com/

Alternatively check UI Automation from Microsoft: http://msdn.microsoft.com/en-us/library/ms747327.aspx and also white: http://white.codeplex.com/

这篇关于从脚本驱动 Windows GUI 程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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