Advertisement
asweigart

Untitled

Sep 26th, 2018
245
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.46 KB | None | 0 0
  1. from pynput import mouse
  2.  
  3. def on_move(x, y):
  4. print('pointer moved to {0}'.format((x,y)))
  5.  
  6. def on_click(x, y, button, pressed):
  7. print('{0} at {1}'.format('pressed' if pressed else 'released', (x,y)))
  8. return False
  9.  
  10. def on_scroll(x, y, dx, dy):
  11. print('scrolled {0} at {1}'.format('down' if dy < 0 else 'up', (x, y)))
  12.  
  13. with mouse.Listener(
  14. on_move=on_move,
  15. on_click=on_click,
  16. on_scroll=on_scroll) as listener:
  17. listener.join()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement