python3 驱动自动安装脚本

from pywinauto.application import Application
import os
import time
os.system('start C:/Users/Administrator/Desktop/APD_507_T82II.exe')
time.sleep(5)
#连接软件
app = Application(backend='win32')
app.connect(title_re='EPSON Advanced Printer Driver Ver.5',class_name='#32770')
time.sleep(1)
dw = app.window(title_re='EPSON Advanced Printer Driver Ver.5',class_name='#32770')
dw.set_focus()
dw['下一步(&N)'].click()
time.sleep(1)
dw['同意(A)'].click()
time.sleep(1)
dw['安装(I)'].click()
while True:
if dw.window(title='下一步(&N) >',class_name='Button').exists():
break
dw['下一步(&N) >'].click()
#app['EPSON Advanced Printer Driver Ver.5'].Close()
#连接新窗口
bpp = Application(backend='win32')
print ("请稍后.....程序正在执行中")
bpp.connect(title_re='注册、更改和删除EPSON TM Printer',class_name='#32770',timeout=20)
dw = bpp.window(title_re='注册、更改和删除EPSON TM Printer',class_name='#32770')
dw.ComBox2.select(3)
dw.ComBox2.select('USB')
dw['设为默认打印机'].click()
dw['保存设置 (S)'].click()
dw = bpp.window(title='PrinterReg', class_name='#32770')
dw['否(N)'].click()
dw = bpp.window(title_re='注册、更改和删除EPSON TM Printer',class_name='#32770')
dw['下一步'].click()
print ("请稍后.....程序正在执行中")
dw = bpp.connect(title_re='EPSON Advanced Printer Driver Ver.5',class_name='#32770',timeout=20)
dw.window(title_re='EPSON Advanced Printer Driver Ver.5',class_name='#32770')
while True:
if dw.window(title_re='关闭(C)',class_name='Button').exists():
break
dw['关闭(C)'].click()
print ("打印机驱动安装完毕")
-------------------------------
该程序未编写界面,直接打包成执行脚本。
posted @ 2019-10-17 23:28  Demo_one  阅读(1022)  评论(0编辑  收藏  举报