【摘要】 参考文章:http://www.chenxm.cc/post/633.html?csdn 安装 pip install pyautogui 官网: http://pyautogui.readthedocs.io/en/latest/ github: https://github.com/asweigart/pyautogui 介绍: ...
参考文章:http://www.chenxm.cc/post/633.html?csdn
安装
pip install pyautogui
官网:
http://pyautogui.readthedocs.io/en/latest/
github:
https://github.com/asweigart/pyautogui
介绍:
PyAutoGUI可以模拟移动鼠标,单击鼠标,用鼠标拖动,按键,按住键,还可以按键盘热键组合。
基础操作
>>> import pyautogui # 获取屏幕尺寸 >>> screenWidth, screenHeight = pyautogui.size() # 获取当前坐标位置 >>> currentMouseX, currentMouseY = pyautogui.position() # 鼠标移动到坐标为100,150的位置 >>> pyautogui.moveTo(100, 150) # 鼠标左击 >>> pyautogui.click() # 鼠标移动10个像素 >>> pyautogui.moveRel(None, 10) # move mouse 10 pixels down # 鼠标双击 >>> pyautogui.doubleClick() >>> pyautogui.moveTo(500, 500, duration=2, tween=pyautogui.easeInOutQuad) # use tweening/easing function to move mouse over 2 seconds. # 键盘输入Hello world! 间隔为0.25秒>>> pyautogui.typewrite('Hello world!', interval=0.25) # type with quarte