()
# 滚动鼠标,第一个参数为 y 滚动的数值,第二个参数为 x 滚动的数值
m.scroll(0, -10)
2.7、监听鼠标的事件
鼠标中的事件有三个,点击事件、移动事件、滚动事件,我们看看如何监听鼠标的事件...:
from pynput import mouse
def on_move(x, y):
"""鼠标移动的监听方法 x,y 为移动后的位置"""
print('鼠标移动到了{0}'....format((x, y)))
def on_click(x, y, button, pressed):
"""鼠标点击的监听方法 x,y 为坐标,button 为按钮,pressed 为是否是按下..."""
if pressed:
print('点击了({0}, {1})'.format(x, y))
else:
print('鼠标在({0}, {1}...)松开'.format(x, y))
def on_scroll(x, y, dx, dy):
"""鼠标滚动的监听方法 x,y 为作为,dx,dy 为滚动幅度"""
print('鼠标在