I have a very simple chunk of code that is designed to simulate keyboard events. The simple example below should type \"Cz\" - the shift key goes down, the c key goes down,
I had a similar problem recently. Instead of passing NULL as the first argument of CGEventCreateKeyboardEvent, create an event source like this:
CGEventSourceRef eventSource = CGEventSourceCreate(kCGEventSourceStateHIDSystemState);
and use it while you are creating and posting events. CFRelease it when you are done with it.