Guest User

Untitled

a guest
Dec 13th, 2018
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.79 KB | None | 0 0
  1. #import <CoreGraphics/CoreGraphics.h>
  2. #import <CoreFoundation/CoreFoundation.h>
  3.  
  4. static int counter = 0;
  5.  
  6. CGEventRef myCGEventCallback(CGEventTapProxy proxy, CGEventType type, CGEventRef event, void *refcon) {
  7.  
  8. printf("event 0x%in ", counter++);
  9.  
  10. return event;
  11. }
  12.  
  13.  
  14. int main(int argc, const char * argv[]) {
  15.  
  16.  
  17. CFRunLoopRef runner = CFRunLoopGetCurrent();
  18.  
  19.  
  20.  
  21.  
  22.  
  23. CFMachPortRef mach = CGEventTapCreate(kCGEventSourceStateHIDSystemState,kCGTailAppendEventTap , kCGEventTapOptionDefault, kCGEventMaskForAllEvents, myCGEventCallback, NULL);
  24.  
  25.  
  26. CFRunLoopSourceRef runLoopSource = CFMachPortCreateRunLoopSource(kCFAllocatorDefault, mach, 0);
  27.  
  28. CFRunLoopAddSource(runner, runLoopSource, kCFRunLoopCommonModes);
  29.  
  30. CGEventTapEnable(mach, true);
  31.  
  32.  
  33. CFRunLoopRun();
  34.  
  35. printf("endn");
  36.  
  37.  
  38.  
  39. }
Add Comment
Please, Sign In to add comment