from PyObjCTools import AppHelper from Foundation import NSObject, NSAppleEventManager, NSTask import struct GURL, keyDirectObject = struct.unpack('ll', 'GURL----') class UggcEventHandler(NSObject): def handleEvent_withReplyEvent_(self, event, replyEvent): theURL = event.descriptorForKeyword_(keyDirectObject).stringValue() NSTask.launchedTaskWithLaunchPath_arguments_( "/usr/bin/open", [theURL.decode("rot-13")]) ue = UggcEventHandler.alloc().init() manager = NSAppleEventManager.sharedAppleEventManager() manager.setEventHandler_andSelector_forEventClass_andEventID_( ue, 'handleEvent:withReplyEvent:', GURL, GURL) if __name__ == '__main__': AppHelper.runEventLoop()