Created
April 11, 2017 02:49
-
-
Save brentvollebregt/6e53b013d36ff7be3cf146948c763a51 to your computer and use it in GitHub Desktop.
A Python 3 mouselogger using the pynput module
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# From: https://github.com/moses-palmer/pynput | |
from pynput.mouse import Listener | |
import logging | |
log_dir = "" | |
logging.basicConfig(filename=(log_dir + "mouse_log.txt"), level=logging.DEBUG, format='["%(asctime)s", %(message)s]') | |
def on_click(x, y, button, pressed): | |
if pressed: | |
logging.info('"{0}", {1}'.format(button, (x, y))) | |
def on_scroll(x, y, dx, dy): | |
logging.info('"{0}", {1}'.format('Button.scroll', (x, y))) | |
with Listener(on_click=on_click, on_scroll=on_scroll) as listener: | |
listener.join() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment