Skip to content

Instantly share code, notes, and snippets.

@candera
Created October 12, 2012 21:13
Show Gist options
  • Save candera/3881566 to your computer and use it in GitHub Desktop.
Save candera/3881566 to your computer and use it in GitHub Desktop.
Trying to call ApplicationServices via JNA
(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