我应该用什么来控制输入设备等

发布于 2024-09-15 01:51:05 字数 1539 浏览 5 评论 0原文

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

说不完的你爱 2024-09-22 01:51:05

我的 Mac OS X 应用程序将执行以下操作:

  • 能够拦截所有键盘和鼠标输入,无论活动(聚焦)的应用程序如何,并选择阻止它(有效禁用输入)或在收到某些键盘快捷键时采取行动。

CGEventTap

有一个 Mac OS X 菜单栏项目(位于屏幕右上角,电池、网络适配器等旁边)

NSStatusItem

有时能够占据整个屏幕(使用一些 OpenGL 画布来显示动画,就像屏幕保护程序一样)

任何 NSView 可以 执行此操作,但对于 OpenGL,您需要 NSOpenGLView

除了通常的全屏方法之外,您可能更喜欢将视图放在 窗口位于屏幕保护级别。尝试两种方法,看看哪一种最适合您。

有声音。

NSSound

My Mac OS X application would do the following:

  • Be able to intercept all keyboard and mouse input regardless of active (focused) application and select to either block it (effectively disabling input) or act on receipt of certain keyboard shortcuts.

CGEventTap.

Have a Mac OS X menu bar item (at the top right of the screen next to the battery, network adapter, etc.)

NSStatusItem.

Be able to occupy the entire screen at times (with some OpenGL canvas to display animations, much like a screen saver does)

Any NSView can do this, but for OpenGL, you'll want NSOpenGLView specifically.

Alternatively to the usual full-screen method, you might prefer to put the view in a window at the screen-saver level. Try both ways and see which works best for you.

Have sound.

NSSound.

书信已泛黄 2024-09-22 01:51:05

如果您精通基于 C 的语言,那么 Cocoa 是一个很好的起点,并且对于您所描述的任务来说可能是最简单的。从这里开始可可: http://developer .apple.com/mac/library/documentation/Cocoa/Conceptual/CocoaFundamentals/Introduction/Introduction.html

Python 也有一些出色的支持,您可以在此处查找可能包含您需要的模块:http://docs.python.org/library/mac.html

如果您更喜欢 Java,这是我开始寻找您需要的功能的地方: http://developer.apple.com/mac/library/documentation/Java/Conceptual/Java14Development/05-CoreJavaAPIs/CoreJavaAPIs.html

老实说我不确定该推荐哪个,我可以只是说可可可能会为您可能需要的任何集成提供最好的支持。

If you are well versed in C based languages, Cocoa is an excellent place to start and would probably be the easiest for the tasks you describe. Start here for cocoa: http://developer.apple.com/mac/library/documentation/Cocoa/Conceptual/CocoaFundamentals/Introduction/Introduction.html

Python has some excellent support as well, you can look here for modules that may contain what you need: http://docs.python.org/library/mac.html

If you would prefer Java, here is where I would start looking for the functionality you need: http://developer.apple.com/mac/library/documentation/Java/Conceptual/Java14Development/05-CoreJavaAPIs/CoreJavaAPIs.html

I'm not sure honestly which to recommend, I can just say cocoa will probably have the best support for any integration you may need.

节枝 2024-09-22 01:51:05

这最初是一条评论,但变得太大了。

我认为您可以使用 Java 来完成大部分操作 - 例如,菜单图标可以通过 SystemTray API 来完成,该 API 将它们放在 Windows 或 OS X 上的相关位置。之前对此的具体答案: 使用 Java 的 Mac OS 中的系统托盘(菜单附加)图标

关键问题是 Java 是否有 API 可以从操作系统获取“原始”事件,或者仅在焦点位于应用程序时才提供。例如,标准 KeyListener 链接到具有焦点的组件。

然而,考虑到应用程序的性质,我建议使用 Cocoa。这还允许您使用核心动画(Quartz / OpenGL 的更高级别的抽象)。

This started out as a comment but got too big.

I think you could do most of this with Java - menu icons, for instance, can be done through the SystemTray API which puts them in the relevant place on Windows or OS X. A previous specific answer on this : System Tray (Menu Extras) icon in Mac Os using Java

The key question is whether Java has APIs to grab 'raw' events from the OS, or only when focus is on the application. The standard KeyListener, for instance, is linked to a component with focus.

However, given the nature of the application, I'd suggest going with Cocoa. This would also allow you to use Core Animation (a higher level abstraction over Quartz / OpenGL).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文