为什么Pynput没有输出

时间:2019-02-24 04:50:21

标签: mouselistener pynput

我正在尝试使用Pynput生成鼠标移动,代码在这里:https://pynput.readthedocs.io/en/latest/mouse.html#monitoring-the-mouse

from pynput import mouse

def on_move(x, y):
    print('Pointer moved to {0}'.format(
    (x, y)))

def on_click(x, y, button, pressed):
    print('{0} at {1}'.format(
    'Pressed' if pressed else 'Released',
    (x, y)))
    if not pressed:
        # Stop listener
        return False

def on_scroll(x, y, dx, dy):
    print('Scrolled {0} at {1}'.format(
    'down' if dy < 0 else 'up',
    (x, y)))

# Collect events until released
with mouse.Listener(
    on_move=on_move,
    on_click=on_click,
    on_scroll=on_scroll) as listener:
    listener.join()

我试图在IPython或python终端中运行代码,但无法生成任何输出。

您知道在移动鼠标时如何看到鼠标移动输出吗?

0 个答案:

没有答案