启动easyconnect后,运行该脚本,实现自动重连。需要填一下连接的地址,用户名和密码(替换一下脚本里的xxx)
from pywinauto import application
from pywinauto import timings
import time# 初始化应用程序对象
app1 = application.Application()
app2 = application.Application()
app3 = application.Application()# 检测是否存在标题为"EasyConnect"的窗口
while True:try:app1.connect(title_re="EasyConnect", found_index=0)window = app1.window(title_re="EasyConnect", found_index=0)# window.set_focus()button = window.child_window(class_name="Button", found_index=0)button.click()button.click()# time.sleep(1)app2.connect(title_re="EasyConnect", found_index=1)window = app2.window(title_re="EasyConnect", found_index=0)# window.set_focus()button = window.child_window(class_name="Button", found_index=0)button.click()button.click()time.sleep(1)# # 填写用户名# window1.print_control_identifiers(depth=None, filename=None)app3.connect(title_re="EasyConnect", found_index=0)window = app3.window(title_re="EasyConnect", found_index=0)edit_control = window.child_window(class_name="Edit", found_index=0)edit_control.set_edit_text("xxx")login_button = window.child_window(class_name="Button", found_index=1)login_button.click()username_edit = window.child_window(class_name="Edit", found_index=1)username_edit.set_edit_text("xxx")password_edit = window.child_window(class_name="Edit", found_index=2)password_edit.set_edit_text("xxx")# 模拟点击登录按钮 (如果有)login_button = window.child_window(class_name="Button", found_index=0)login_button.click()print("用户名和密码已成功填写")except Exception as e:# print(str(e))pass