Python脚本 - 自动化操作鼠标键盘

安装依赖库

Python操作鼠标键盘需要安装 pynput 库,安装命令如下(VS Code执行)

python.exe -m pip install -i https://pypi.tuna.tsinghua.edu.cn/simple pynput

获取鼠标位置

from pynput.mouse import Controller
import time

time.sleep(3)
mouse = Controller()
print('The current pointer position is {0}'.format(mouse.position))

运行结果

PS D:\> & C:/Python27/python.exe d:/Python/鼠标键盘操作/getMouse.py
The current pointer position is (647, 671)

猜你喜欢

转载自blog.csdn.net/hjt6927818/article/details/124341487
今日推荐