阻止所有键盘访问,鼠标访问和键盘快捷方式事件 [英] block ALL keyboard access, mouse access and keyboard shortcut events

查看:152
本文介绍了阻止所有键盘访问,鼠标访问和键盘快捷方式事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

为了在我的一个项目中阻止所有键盘访问,鼠标访问和键盘快捷方式事件,我:


  1. 创建完整

  2. 使用简单的 return; 处理所有键盘和鼠标事件

  3. 使窗口 modal [NSApp runModalForWindow:myWindow] 要阻止键盘快捷键。

  4. > $ <$> $

    但是这个人在一个小应用程序中看起来很简单 - MACIFIER : / p>

    他是如何做到的?

    解决方案

    Quartz Event Services 。具体来说,请查看 CGEventTapCreate ,并注意第四个参数,它允许您指定要拦截哪些类型的事件。可用的事件类型列在 CGEventType 枚举。



    如果将抽头设置为活动过滤器,则返回 NULL 从该回调将删除该事件。


    In order to block ALL keyboard access, mouse access and keyboard shortcut events in one of my projects, I:

    1. Created a full screen transparent borderless window, in front of other windows, but invisible.
    2. Handle all keyboard and mouse events with simple return; the window itself.
    3. Make the window modal [NSApp runModalForWindow:myWindow] in order to block keyboard shortcuts.
    4. Release window from touchpad's gesture events only.

    But this guy made it look simple in a tiny app -MACIFIER:

    How did he do it?

    解决方案

    I believe you can use Quartz Event Services. In particular, have a look at CGEventTapCreate, and note the 4th parameter, which allows you to specify what kinds of events you'd like to intercept. The available kinds of events are listed in the CGEventType enum.

    If you set your tap to be an active filter, returning NULL from the callback will delete the event.

    这篇关于阻止所有键盘访问,鼠标访问和键盘快捷方式事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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