block ALL keyboard access, mouse access and keyboard shortcut events

时光怂恿深爱的人放手 提交于 2019-12-07 12:49:53

问题


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?


回答1:


not really sure if this would be usable, but you could use the program hotkeynet (generally used for gaming, but I have had success using other methods) and map every single key/mouse action to do nothing. I did something similar by blocking access to a specific program with it in about 20-30 minutes.

not sure if it will help; but it might be the solution you need?




回答2:


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.



来源:https://stackoverflow.com/questions/11336160/block-all-keyboard-access-mouse-access-and-keyboard-shortcut-events

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!