开发者

Catching events in Mac OS X

Does anyone know how to catch events in Mac OS X ? My problem is that I need to intercept for example a MOUSEKEYDOWN开发者_开发技巧 or maybe a KEYSTROKE before the event arrives to any application. My objective is to block the event or change the data it could contain. I read something about the kEvent class but I could not find some sample to understand how to begin programming with it.


Try Quartz Event Taps. You can explore how they work with Event Taps Testbench or read the documentation.


As far as I know you can use the Carbon API to register to events and modify them. Modifying the event is not possible if you use Cocoa, i.e. the NSEvent class, which can only be observed. I used this tutorial to get started with the Carbon API myself. I found it really hard to find any tutorials not using Cocoa, so I hope that helps.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜