daily pastebin goal
53%
SHARE
TWEET

Untitled

a guest Dec 13th, 2018 52 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top