I need to send a keystroke to the target application, and my first requests led me to CGEventCreateKeyboardEvent :
CGEventRef eventA = CGEventCreateKeyboardEvent(NULL, (CGKeyCode)0, true);
CFRelease(eventA);
This compiled, but did nothing, but in the process of trying to find out, I found this ...
CGPostKeyboardEvent( (CGCharCode)'a', (CGKeyCode)0, true);
... and it worked. What for? From what I have read so far about this, they should do the same thing, but CGPostKeyboardEvent is deprecated.
(Forgive me if I ignore the details that I should explicitly include - I am stepping out of my usual depth trying to help colleagues with an after-school project and just trying to find out something along the way.)
source
share