PyAutoGUI

7.1 安装 PyAutoGUI

1
pip3 install pyautogui

7.2 控制鼠标

1
2
pyautogui.onScreen(x, y)  # True if x & y are within the screen.
True

每次控制鼠标暂停一下,避免失败

1
pyautogui.PAUSE = 2.5

参考文档

https://pyautogui.readthedocs.io/en/latest/quickstart.html

7.3 控制键盘

1
pyautogui.write('Hello world!')
1
pyautogui.press('enter')
1
pyautogui.hotkey('ctrl', 'shift', 'esc')

7.4 截屏

1
pyautogui.screenshot('my_screenshot.png')

7.5 提示信息

1
alert(text='', title='', button='OK')

视频课程

西瓜视频 https://www.ixigua.com/6850961503709987336/