pynput.mouse.Listener特定抑制(Python)
我有一段代码,它监听鼠标事件,并使用pynput.mouse.Listener特定抑制(Python),python,mouseevent,mouse,pynput,Python,Mouseevent,Mouse,Pynput,我有一段代码,它监听鼠标事件,并使用suppress=True来防止 事件不会被传递到系统的其余部分。(将鼠标锁定到位并阻止所有输入) 问题是我只想抑制鼠标的输入(点击,滚动),而不想抑制移动(移动) 我该怎么做 def on_move(x, y): print(x, y) def on_click(x, y, button, pressed): print(button, pressed def on_scroll(x, y, dx, dy): print(dx,
suppress=True
来防止
事件不会被传递到系统的其余部分。(将鼠标锁定到位并阻止所有输入)
问题是我只想抑制鼠标的输入(点击
,滚动
),而不想抑制移动(移动
)
我该怎么做
def on_move(x, y):
print(x, y)
def on_click(x, y, button, pressed):
print(button, pressed
def on_scroll(x, y, dx, dy):
print(dx, dy)
with pynput.mouse.Listener(on_move=on_move, on_click=on_click, on_scroll=on_scroll, suppress=True) as listener:
listener.join()