Created
October 12, 2012 21:13
-
-
Save candera/3881566 to your computer and use it in GitHub Desktop.
Trying to call ApplicationServices via JNA
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(def eventcount (atom 0)) | |
(def i khordr.ApplicationServicesLibrary/INSTANCE) | |
(def eventTap (.CGEventTapCreate | |
i | |
khordr.ApplicationServicesLibrary$CGEventTapLocation/kCGSessionEventTap | |
khordr.ApplicationServicesLibrary$CGEventTapPlacement/kCGHeadInsertEventTap | |
0 | |
khordr.ApplicationServicesLibrary$CGEventType/kCGEventKeyDown | |
(reify khordr.ApplicationServicesLibrary$CGEventTapCallback | |
(onevent [this _ _ event _] (swap! eventcount inc) nil)) | |
nil)) | |
(def runLoopSource (.CFMachPortCreateRunLoopSource | |
i | |
nil | |
eventTap | |
0)) | |
(.CFRunLoopAddSource | |
i | |
(.CFRunLoopGetCurrent i) | |
runLoopSource | |
(.getPointer (.getGlobalVariableAddress (com.sun.jna.NativeLibrary/getInstance "ApplicationServices") "kCFRunLoopCommonModes") | |
0)) | |
(.CGEventTapEnable i eventTap true) | |
(.CFRunLoopRun i) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment