views:

2127

answers:

3

A Java6 application sits in the system tray. It needs to be activated using a hotkey (e.g. Super-G or Ctrl-Shift-L etc) and do something (e.g. showing an input box).

How do I do that on:

  • Windows (XP or Vista)
  • OS/X
  • Linux (Gnome or KDE)
+5  A: 

It seems that this is not doable in a cross-platform fashion without using the native interfaces.

On Windows, you can use the free JIntellitype library.

Antti Sykäri
+4  A: 

For Linux (X11) there is JXGrabKey: http://sourceforge.net/projects/jxgrabkey/

There is also a tutorial for grabbing a global hotkey on Linux: http://ubuntuforums.org/showthread.php?t=864566

I didn't though find a solution for OS X yet.

To build something for all 3 platforms I'd suggest stripping down JIntellitype (it's Apache license) to it's global hotkey functionality and extending it with the OS X and X11 functionality...

Torsten Uhlmann
_Update_: I have started to develop my own cross platform global hotkey library, called OsSupport. I have uploaded the code to BitBucket under Apache 2.0 license: https://bitbucket.org/agynamix/ossupport-connector.Currently OsSupport only supports Mac because of other existing solutions for Windows and Linux. However the library is designed to be cross platform and also support other things than hotkeys. For instance OsSupport can send key press events to the system in order to simulate a key press.
Torsten Uhlmann
+2  A: 

If anyone wants to do the OSX or Linux versions of the JNI part of Jintellitype I would be more than happy to add those to the JIntellitype library.

Melloware

http://www.melloware.com