2013-11-14 38 views
0

我想在窗口上使用python运行我的外部(.exe)程序。为了运行该程序(.exe)的特定任务,我需要知道方法并在我的test.py(我的python文件)中调用,我如何在我的python中调用函数?python,编写代码来自动执行外部程序并使用该方法来执行程序的任务

import subprocess 
subprocess.call(['C:\\EnergyPlusV7-2-0\EP-Launch.exe', 'C:\\modelo_0001.idf']) 

现在我需要通过Python来调用一个方法来运行外部程序(.exe文件)一个特定的任务,但如何?有人可以给我一个例子格式?有一个按钮说'模拟',我需要获得该按钮的方法,以便我可以通过python执行它!

回答

0

您应该尝试使用pywinauto:http://code.google.com/p/pywinauto/ 安装并阅读文档。

例如:

from pywinauto import application 
app = application.Application.start("C:\\EnergyPlusV7-2-0\\EP-Launch.exe") 
# open dialog here with pywinauto (see docs), it's bound to interface can't help here 
# press next button 

还应考虑SWAPY它会产生pywinauto自动化Python代码。

http://code.google.com/p/swapy/