我的第一个python程序,自动运行第三方程序

首先要配置python3.7.0,并且用pip安装pyautogui。编写my_app.py的脚本如下:

import pyautogui   #导入pyautogui库
import time
pyautogui.PAUSE = 0.5
# 打开hydrus软件
pyautogui.click(10, 780, clicks = 2)
# 打开open
pyautogui.keyDown('Alt')
pyautogui.press(['F'])
pyautogui.keyUp('Alt')
time.sleep(1)
pyautogui.press(['O'])
time.sleep(1)
# 填入
pyautogui.write('ShenZhouZhong2.h1d', interval=0.25)
pyautogui.moveTo(780, 1000, duration = 0.5)
pyautogui.press('return')
time.sleep(1)

# 运行
pyautogui.keyDown('Alt')
pyautogui.press(['C'])
pyautogui.keyUp('Alt')
pyautogui.press(['E'])
pyautogui.moveTo(780, 1000, duration = 0.5)
pyautogui.press('return')
time.sleep(1)
pyautogui.press('enter')



在dos下运行: