本意:使用 Python 模拟打开 crt 并执行相关脚本的操作
进度:已实现
模拟步骤:
使用注意事项
参考资料
实现代码
import pyautogui as pg
import os
import time
import subprocess
from threading import Thread
pg.keyDown('super')
pg.press('r')
pg.keyUp('super')
time.sleep(1)
# 使用运行调用 crt
pg.write('securecrt.exe')
pg.press('enter')
time.sleep(10)
# 输入执行脚本的快捷键
pg.keyDown('alt')
pg.press('s')
time.sleep(1)
pg.press('r')
pg.keyUp('alt')
time.sleep(1)
crt_script_path = 'D:\Projects\AutoCRT'
# 调用脚本打开连接
script1 = os.path.join(crt_script_path, 'openTab.py')
pg.write(script1)
pg.press('enter')
time.sleep(5)
pg.keyDown('alt')
pg.press('s')
time.sleep(1)
pg.press('r')
pg.keyUp('alt')
time.sleep(1)
# 调用脚本a执行
script1 = os.path.join(crt_script_path, 'job_a.py')
pg.write(script1)
pg.press('enter')
pg.keyDown('alt')
pg.press('s')
time.sleep(1)
pg.press('r')
pg.keyUp('alt')
time.sleep(1)
# 调用脚本b执行
script1 = os.path.join(crt_script_path, 'job_b.py')
pg.write(script1)
pg.press('enter')