0

New to macOS and trying some PoCs. Following is code that runs well if I choose the Project template as App, however, when I used Command Line Tool as the Project template in XCode, I do not receive events.

Accessibility access is enabled for my Application and there is no Sandboxing otherwise. I also tried to test addLocalMonitorForEvents in Command Line Tool App, and the result is same, no event.

Is there a restriction in using events' monitor in "Command Line Tool"?

               func event(e: NSEvent?) {
                print(e.windowNumber)
            }
            
            NSEvent.addGlobalMonitorForEvents(matching: [NSEvent.EventTypeMask.leftMouseDown], handler: event)
vibhu
  • 1,657
  • 2
  • 15
  • 19
  • Does this answer your question? [NSEvent addGlobalMonitorForEventsMatchingMask not working on CLI app](https://stackoverflow.com/questions/21894499/nsevent-addglobalmonitorforeventsmatchingmask-not-working-on-cli-app) – TheNextman Apr 28 '23 at 13:34

0 Answers0