本文介绍了作出这样的监听系统范围的快捷方式的AppleScript程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想创建某种后台进程侦听所有击键事件,因此行为(例如做一些动作,如果CMD-A是pressed而在Finder.app,或更复杂的事情,比如序列创建快捷方式就像在Emacs ..)

I'd like to create some kind of background process that listens to all keystrokes event and acts consequently (for example does some action if CMD-A is pressed while in Finder.app, or more complex things, like sequences to create shortcuts like in emacs..)

但我怎么能听键presses系统范围的雪豹?
我以为AppleScript的..但没有发现任何..结果
(我擅长的红宝石也是如此,并打算用RB-appscript实际上)

But how can I listen to keypresses systemwide on SnowLeopard?I thought of Applescript.. but found nothing..
(I'm good at ruby too, and intended to use rb-appscript actually)

谢谢!

推荐答案

如果你真的想捕获所有击键系统范围内,需要 CGEventTap 。我不认为这是直接提供给AppleScript的,也许在10.6您可以使用 AppleScriptObjC 。当然,它应该通过桥支持。

If you really want to capture all the keystrokes system-wide, you need CGEventTap. I don't think it's available directly to AppleScript, maybe on 10.6 you can use AppleScriptObjC. Surely it should be available to Ruby via Bridge Support.

然而,全系统的键盘听者会经常调用。我建议code C或对象 - 相反,这将是更有效的。

However, a system-wide keyboard listener would be called very often. I would suggest to code in C or Obj-C instead, which would be more efficient.

这篇关于作出这样的监听系统范围的快捷方式的AppleScript程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-01 16:03