Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #import <CoreGraphics/CoreGraphics.h>
- #import <CoreFoundation/CoreFoundation.h>
- static int counter = 0;
- CGEventRef myCGEventCallback(CGEventTapProxy proxy, CGEventType type, CGEventRef event, void *refcon) {
- printf("event 0x%in ", counter++);
- return event;
- }
- int main(int argc, const char * argv[]) {
- CFRunLoopRef runner = CFRunLoopGetCurrent();
- CFMachPortRef mach = CGEventTapCreate(kCGEventSourceStateHIDSystemState,kCGTailAppendEventTap , kCGEventTapOptionDefault, kCGEventMaskForAllEvents, myCGEventCallback, NULL);
- CFRunLoopSourceRef runLoopSource = CFMachPortCreateRunLoopSource(kCFAllocatorDefault, mach, 0);
- CFRunLoopAddSource(runner, runLoopSource, kCFRunLoopCommonModes);
- CGEventTapEnable(mach, true);
- CFRunLoopRun();
- printf("endn");
- }
Add Comment
Please, Sign In to add comment