PyAutoGUI一个纯Python的GUI自动化工具,其目的是可以用程序自动控制鼠标和键盘操作,多平台支持(Windows, Mac Os, Linux)
GitHub: https://github.com/asweigart/pyautogui
pip安装:>pip install pyautogui
文档: https://pyautogui.readthedocs.io/en/latest
import pyautogui
from time import sleep
# x, y = pyautogui.size()
# print(x)
# print(y)
# pyautogui.moveTo(x/2, y/2)
#
# pyautogui.moveTo(347, 454)
# pyautogui.click()
# pyautogui.typewrite("hello world", interval=0.1)
# pyautogui.press('esc')
# pyautogui.keyDown('shift')
# sleep(1)
# pyautogui.press(['left', 'left','left','left','left'])
# sleep(1)
# pyautogui.keyUp('shift')
# sleep(1)
# pyautogui.hotkey('ctrl', 'c')
# sleep(1)
# pyautogui.press("right")
# pyautogui.hotkey('ctrl', 'v')
"""
hello world
"""
# # 警告框
# pyautogui.alert('这个消息弹窗是文字+OK按钮')
# # 截图
# pyautogui.screenshot('foo.png')
# 例子,打开chrome浏览器,访问百度
pyautogui.hotkey('win', 'q')
sleep(1)
pyautogui.typewrite("chrome", interval=0.25)
sleep(1)
pyautogui.press("enter")
sleep(2)
pyautogui.typewrite("www.baidu.com")
sleep(1)
pyautogui.press("enter")