JIntellitype Emil A Lefkof III

Here is a simple quick start for getting up and running with JIntellitype quickly. An Example is also included in the distribution to show you how easy it is to use JIntellitype.

If you are familiar with Eclipse there is a full working example Eclipse project that can be found here Eclipse Example. In Eclipse just navigate to File->Import->Existing Project Into Workspace and you are ready to go.

1. Make sure JIntellitype.dll is in your PATH or in \Windows\System32.

2. Initialize a JIntellitype object. // Initialize JIntellitype ... JIntellitype.getInstance(); ... // OPTIONAL: check to see if an instance of this application is already // running, use the name of the window title of this JFrame for checking if (JIntellitype.checkInstanceAlreadyRunning("MyApp")) { LOG.error("An instance of this application is already running"); System.exit(1); }

3. To listen to hotkey's, you need to register the combinations to listen for. // Assign global hotkeys to Windows+A and ALT+SHIFT+B JIntellitype.getInstance().registerHotKey(1, JIntellitype.MOD_WIN, (int)'A'); JIntellitype.getInstance().registerHotKey(2, JIntellitype.MOD_ALT + JIntellitype.MOD_SHIFT, (int)'B'); //or you can use the Swing constants instead JIntellitype.getInstance().registerSwingHotKey(3, Event.CTRL_MASK + Event.SHIFT_MASK, (int)'C'); // To unregister them just call unregisterHotKey with the unique identifier JIntellitype.getInstance().unregisterHotKey(1); JIntellitype.getInstance().unregisterHotKey(2); JIntellitype.getInstance().unregisterHotKey(3);

4. Make sure to add a HotKeyListener and implement the interface. //assign this class to be a HotKeyListener JIntellitype.getInstance().addHotKeyListener(this); // listen for hotkey public void onHotKey(int aIdentifier) { if (aIdentifier == 1) System.out.println("WINDOWS+A hotkey pressed"); } }

5. To use Intellitype commands implement the IntellitypeListener interface. //assign this class to be a IntellitypeListener JIntellitype.getInstance().addIntellitypeListener(this); // listen for intellitype play/pause command public void onIntellitype(int aCommand) { switch (aCommand) { case JIntellitype.APPCOMMAND_MEDIA_PLAY_PAUSE: System.out.println("Play/Pause message received " + Integer.toString(aCommand)); break; default: System.out.println("Undefined INTELLITYPE message caught " + Integer.toString(aCommand)); break; } }

6. Don't forget to call the cleanup method to release the DLL resources. // Termination, make sure to call before exiting ... JIntellitype.getInstance().cleanUp(); System.exit(0);