Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python
- from AppKit import NSWorkspace
- from Cocoa import *
- from Foundation import *
- from PyObjCTools import AppHelper
- import socket
- sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
- class AppDelegate(NSObject):
- def applicationDidFinishLaunching_(self, aNotification):
- NSEvent.addGlobalMonitorForEventsMatchingMask_handler_(NSKeyDownMask, handler)
- def handler(event):
- if NSWorkspace.sharedWorkspace().activeApplication()['NSApplicationName'] == 'Corona Simulator':
- s = unicode(event).split(' ')
- if s[8]:
- s = s[8][-2:-1]
- if (s >= 'a' and s <= 'z') or s == '`' or s == '[' or s == ']':
- sock.sendto(s, ('127.0.0.1', 5000))
- def main():
- app = NSApplication.sharedApplication()
- delegate = AppDelegate.alloc().init()
- NSApp().setDelegate_(delegate)
- AppHelper.runEventLoop()
- if __name__ == '__main__':
- main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement