用pywinauto 自动启动exe并且填写edit 控件,按按钮 (python 3.7.4 )


from pywinauto.application import Application
import time
import pyautogui
app = Application(backend="uia").start("C:\\Users\\PENG CAN\Desktop\\授权工具v2.24\\GIDSAuthTool.exe")
#1.QQ自动安装
#app = application.Application().start('C:\\Users\\PENG CAN\Desktop\\授权工具v2.24.exe')
time.sleep(1)
##########################################密码窗口 1st
window_title='GIDSAuthTool v2.24'
#3.查看一个窗体含有的控件,子窗体,菜单
#print(app[window_title].print_control_identifiers())
#app.window(class_name = window_title).draw_outline(colour ='red')
Gdlg = app.window_(title_re=window_title)

Gdlg.wait("exists ready", timeout = 5, retry_interval = 3)
Gdlg.draw_outline(colour="red")
#Gdlg.print_control_identifiers()

#while (1):
  #  print(1)
#####输入密码######

pyautogui.typewrite(message='GAC2019',interval=0)
pyautogui.press('enter')


######################2nd 窗口,主界面,#################
window_title='GIDSAuthTool v2.24'
#3.查看一个窗体含有的控件,子窗体,菜单
#print(app[window_title].print_control_identifiers())
#app.window(class_name = window_title).draw_outline(colour ='red')
Gdlg = app.window_(title_re=window_title)


Gdlg.wait("exists ready", timeout = 5, retry_interval = 3)
Gdlg.draw_outline(colour="red")
Gdlg.print_control_identifiers()
#Gdlg.child_window(title="申请码:", auto_id="textBoxApply", control_type="Edit")

Gdlg.child_window(title="申请码:", auto_id="textBoxApply", control_type="Edit").set_edit_text('TJJJJJJJJJJJJJJJJJ4TAVJQIOKPJII6')
#app[window_title].child_window(title="申请码",control_type="Edit").set_edit_text('TJJJJJJJJJJJJJJJJJ4TAVJQIOKPJII6')
#time.sleep(2)
Gdlg.child_window(title="退出(X)",auto_id="btnExit", control_type="Button").click()


你可能感兴趣的:(用pywinauto 自动启动exe并且填写edit 控件,按按钮 (python 3.7.4 ))