I'm completely stuck with logic that's been working for many years now. I'm using this to listen to keyboard events (hotkeys) while the app is in background.
CFMachPortRef eventTap = CGEventTapCreate(kCGSessionEventTap,
kCGHeadInsertEventTap,
kCGEventTapOptionDefault,
CGEventMaskBit(kCGEventKeyDown) | CGEventMaskBit(kCGEventFlagsChanged),
myCGEventCallback,
nil);
if (!eventTap) {
printf("error: event tap register failed\n");
return false;
}
The code has not changed, and this has worked for a long time until the latest update to mojave. How can I go about troubleshooting the reason for this? Would anyone know how I can get this working again?
Got this working after some fighting. Add this to your info.plist:
<key>NSAppleEventsUsageDescription</key>
<string></string>
Then go to your system preferences -> security -> privacy -> accessibility, and ensure your app is there and checked.
If it's already there and this keeps happening, remove it and add it again. I have to do this every time I rebuild my app...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With