开发者

how can i send a keyboard event to the app through pressing a button?

in fact i am building a virtual开发者_开发知识库 keyboard how can i send a keyboard event to the program through pressing a button? thanks


You could use Quartz Event Servcices.
They provide CGEventCreateKeyboardEvent which allows you to emulate any physical key-press.
The API is modeled after real key events.
So you have to call "Shift" + "Character" to get an upper case letter. You also need to release keys you have pressed.
Apple's documentation contains sample code.

Update:
We are talking about Mac OS X, right? Please add some tags to your original question.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜