LSUIElement 应用程序具有响应能力
我有一个应用程序,其中我将 LSUIElement 键设置为 1,以便它在后台运行并且不会在 Dock 中显示图标。 我的意愿是使应用程序响应击键或鼠标事件。实际上,主窗口仅在应用程序启动时出现。当主窗口可见时,击键可以正确处理,但如果我关闭它,就无法再次显示它(因此击键将被忽略)。我希望我的应用程序能够在我按下特定组合键时做出响应(就像 Scribblet 为那些知道它的人所做的那样)。 谁能告诉我在哪里可以找到有关如何执行此操作的信息?
I have an application in which I set the LSUIElement key to 1, so that it runs in background and does not show the icon in Dock.
My will is to make the application responsive to keystrokes or mouse events. Actually the main window appear only when the app is launched. With the main window visible, keystrokes are handled correctly, but if I close it there's no way to show it again (and so keystrokes are ignored). I want my application to be responsive any time I push a particular key combination (as i.e. Scribblet does for those who know it).
Can anyone tell me where I can find information about how to do this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
状态栏应用程序仅处于活动状态,因此您的应用程序只能在窗口或菜单已打开时接收事件。
您的应用程序可以通过设置 事件点击:
这将允许您的应用程序检查
keyDown
事件在路由到其他应用程序之前。请参阅 回调 了解回调函数的外观和行为方式。GitHub 上还有一个由 Dave DeLong 编写的可能更易于使用的 Cocoa 类:DDHotKey。
The status bar application is only active, and thus your application can only receive events, when the window or the menu is already open.
Your application can implement a "hot key" by setting up an Event Tap:
This will allow your application to inspect
keyDown
events before they are routed to other applications. See Callbacks for how your callback function needs to look and behave.There's also a probably easier-to-use Cocoa class written by Dave DeLong available on GitHub: DDHotKey.