PyAutoGUI是一个纯Python的GUI自动化工具,其目的是可以用程序自动控制鼠标和键盘操作,利用它可以实现自动化任务。PyAutoGUI可以模拟鼠标的移动、点击、拖拽,键盘按键输入、按住操作,以及鼠标+键盘的热键同时按住等操作,可以说手能动的都可以。
PyAutoGUI-自动化拟人操作工具
官网
https://pyautogui.readthedocs.io
GitHub
https://github.com/asweigart/pyautogui
安装与依赖
PyAutoGUI支持Python 2.x和Python 3.x
Windows:PyAutoGUI没有任何依赖,因为它用Python的ctypes模块所以不需要pywin32
pip3 install pyautogui
OS X:PyAutoGUI需要PyObjC运行AppKit和Quartz模块。这个模块在PyPI上的按住顺序是pyobjc-core和pyobjc
sudo pip3 install pyobjc-core sudo pip3 install pyobjc sudo pip3 install pyautogui
Linux:PyAutoGUI需要python-xlib(Python 2)、python3-Xlib(Python 3)
sudo pip3 install python3-xlib sudo apt-get scrot sudo apt-get install python-tk sudo apt-get install python3-dev sudo pip3 install pyautogui```
获取当前鼠标的坐标
import pyautogui a = pyautogui.position() print(a)
输出
Point(x=1483, y=744)
当前屏幕的分辨率(宽度和高度)
import pyautogui a = pyautogui.size() print(a)
输出
Size(width=1920, height=1080)
(x,y)是否在屏幕上
import pyautogui x, y = 100, 100 a = pyautogui.onScreen(x, y) print(a)
输出
True

关注公众号『窗外天空』
获取更多建站运营运维新知!互联网创业、前沿技术......
最新评论
感谢分享,谢谢站长!!@天天下载
求同型号
能别用城通吗,缺钱缺这样啊
你好,请问有华硕ac68U可以使用的版本吗
xiaomi mini 是什么架构阿 是mipsel_24kc架构ma