CGEventPost only working when application is debugged

83 views Asked by At

In my application i want to emulate key strokes. Therefore i am using the CGEventPost API.

CGEventRef keyEvent = CGEventCreateKeyboardEvent(NULL, keyCode, down);
(*) CGEventPost(kCGHIDEventTap, keyEvent);
CFRelease(keyEvent);

I build my project with CMake. Once built and executed, the typical permission dialog pops up and i can activate my application in the accessiblity tab. Running the application again and having a breakpoint at the (*) location, emulates the wished key press. However if i start the application from console or remove the breakpoint, no key gets emulated. Does somebody know, what could be the cause of this?

The app should not be sandboxed and is not signed.

0

There are 0 answers