Is it possible to send keystrokes to a cocoa app? I don't want to use AppleScript because I want to do it under the hood, programatically. I开发者_开发技巧s this possible? Thanks.
Have a look at these calls, but you will need to set code
correctly which can be dependent of the currently selected keyboard.
CGEventRef event;
event = CGEventCreateKeyboardEvent (NULL, code, down);
CGEventPost(kCGSessionEventTap, event);
CFRelease(event);
http://developer.apple.com/library/mac/documentation/Carbon/Reference/QuartzEventServicesRef/Reference/reference.html#//apple_ref/c/func/CGEventCreateKeyboardEvent
精彩评论