开发者

Sending keystrokes to cocoa app

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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜