1

I'm researching about pywinauto and pywin32. I want to write a script to automate downloading a file in Firefox. When downloading a file in Firefox, it will show a popup to ask you to open or save the file, and you have to choose an option and follow steps. How can I locate controls (items) on this popup by using pywinauto or pywin32?

4

4 回答 4

1

pywinauto 安装有一个与此相关的示例(SaveFromFirefox.py):http: //pywinauto.googlecode.com/hg/pywinauto/docs/getting_started.html

于 2011-11-21T17:13:28.463 回答
1

你应该调查selenium ide。您可以使用它和 Python 来自动化大部分 Firefox。那里的论坛应该为您指明正确的方向。这个下载问题是一个持久的问题。

祝你好运!

于 2011-10-19T14:58:19.520 回答
0

您可以查看麻省理工学院的Project SIKULI。有了它,您可以通过截屏来编写宏。项目截图使整个过程看起来很容易。它也是基于 Python 的,因此它可能是这项工作的编写工具。

此外,如果您可以控制相关计算机,则可以选中下载弹出窗口中“每次都执行此操作”(或任何确切的措辞)的框。也许这足以使工作更简单?

于 2011-11-13T19:10:14.070 回答
0

对于最新的 Firefox 版本,您可以使用pywinauto 0.5.x(只需下载并运行python setup.py install或运行pip install pywinauto)。SaveFromFirefox.py适用于 Win7。

有用的提示:

  • app.Dialog.PrintControlIdentifiers()将为对话框上的控件打印所有可能的访问名称。
  • SWAPY是用于 pywinauto 的控件层次结构检查和代码生成的 GUI 助手。
  • app.Dialog.ControlName.WrapperObject()....将为您提供可用于控件的最有用的方法列表。在生产代码中,WrapperObject()可以省略调用。
于 2015-02-24T12:51:59.923 回答