利用pywinauto模块打开一个应用,输入参数,点击应用中的按钮,获取数据

1、python的pywinauto模块可以实现操作.exe应用,实现你想实现的功能。

from pywinauto import application

def operateftptools(begindate,enddate):

    dirs = u"E:/Ftp.exe"   #应用所在路径

    app = application.Application()
    app.start(dirs)                      #开始一个进程
    ftptool = app.window_(found_index = 0)     #获取Ftp.exe的主窗口
    ftptool.window_(found_index = 7).TypeKeys(begindate)#发送快捷键,index 7是开始时间文本框
    ftptool.window_(found_index = 9).TypeKeys(enddate)#发送快捷键,index 9是结束时间文本框
    ftptool.window_(found_index = 3).Click()    #index 3 is find data查询数据
    findresult=ftptool.child_window(found_index = 0,class_name = "Button", title = u"确定") #弹出子窗口,查询完成,点击确定  
    findresult.wait('exists',10000)  #如果数据太多,需要把10000改大些   
    print 'the end of finding-data'        
    ftptool.child_window(found_index = 0,class_name = "Button", title = u"确定").DoubleClick()

    app.connect(path = dirs)#连接一个已经打开的进程
    ftptool = app.window_(found_index = 0)   #回到主窗口句柄 
     ftptool.Window_(found_index = 0,class_name = "Button", title = u"保存CSV").Click()#点击保存CSV按钮
    ftptool.child_window(found_index = 0,class_name = "Button", title = u"确定").DoubleClick()#保存csv后弹出子窗口,点击确定,csv文件自动保存到Ftp.exe所在文件夹
    ftptool.close()  #关闭Ftp.exe应用
    print "export blackbox-data successfully"   



 


  • 0
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 3
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值