如何在应用程序未激活时观察键盘输入事件 [英] how do I observe keyboard input event while the applicaion is not actived

查看:115
本文介绍了如何在应用程序未激活时观察键盘输入事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

解决方案

您需要创建一个CGEventTap使用 Quartz Event Services



如果您要设置一个热键,那么用户必须具有访问辅助设备的权限,这是有道理的。 ,碳事件管理器中有一个API ,以及一个名为SGHotKeysLib的Cocoa包装器。请注意,Carbon Event Manager热键API在当前的64位Mac OS X中仍然受支持。


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

解决方案

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.

这篇关于如何在应用程序未激活时观察键盘输入事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆