how do I observe keyboard input event while the ap

2019-06-02 08:14发布

how do I observe keyboard input event while the applicaion is not actived.

1条回答
家丑人穷心不美
2楼-- · 2019-06-02 08:58

You'll need to create a CGEventTap using Quartz Event Services. The user must have access for assistive devices turned on, which makes sense, because that's the only legitimate reason for you to do that.

If you want to set up a hotkey, there's an API in Carbon Event Manager for that, and a Cocoa wrapper named SGHotKeysLib. Note that the Carbon Event Manager hotkey API is still supported in current, 64-bit Mac OS X.

查看更多
登录 后发表回答