Skip to content

Instantly share code, notes, and snippets.

@Sebelino
Last active October 4, 2016 14:39
Show Gist options
  • Save Sebelino/e9ad3b4321e489d5ece69bf70f4e1d92 to your computer and use it in GitHub Desktop.
Save Sebelino/e9ad3b4321e489d5ece69bf70f4e1d92 to your computer and use it in GitHub Desktop.
Key/mouse logger demo with PyUserInput
#!/usr/bin/env python
# The following is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
from pykeyboard import PyKeyboardEvent
from pymouse import PyMouseEvent
from threading import Thread
from time import sleep
class KeyListener(PyKeyboardEvent):
def __init__(self):
PyKeyboardEvent.__init__(self)
def handler(self, reply):
print("Handle keypress here...")
class MouseListener(PyMouseEvent):
def __init__(self):
PyMouseEvent.__init__(self)
def click(self, x, y, button, press):
print("Handle mousepress here...")
if __name__ == '__main__':
keylistener = KeyListener()
mouselistener = MouseListener()
kt = Thread(target=keylistener.run)
mt = Thread(target=mouselistener.run)
kt.start()
mt.start()
while True:
print("Running...")
sleep(10)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment