文件拖放与鼠标拖动

时间:2017-08-04 05:32:08

标签: python linux ubuntu

有没有办法以编程方式监控和区分正常鼠标拖动与抑制(如正常突出显示的读数)和拖动文件(如上传到浏览器)。

下面的代码可以帮助我在拖动鼠标时获取但是我们如何才能进一步区分

from pynput.mouse import Listener

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}'.format(
        (x, y)))

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

0 个答案:

没有答案