diff --git a/pom.xml b/pom.xml index 0445ca3..86d47b5 100644 --- a/pom.xml +++ b/pom.xml @@ -1,16 +1,9 @@ - - org.sonatype.oss - oss-parent - 7 - - - 4.0.0 com.melloware jintellitype jar - 1.3.10-SNAPSHOT + 1.4.0-SNAPSHOT http://www.melloware.com JIntellitype JIntellitype - JNI Java bridge to Microsoft Intellitype commands. @@ -24,8 +17,8 @@ ${default.encoding} ${default.encoding} ${default.encoding} - 1.6 - 1.6 + 1.7 + 1.7 1999 @@ -174,6 +167,57 @@ + + org.apache.maven.plugins + maven-deploy-plugin + 3.0.0-M1 + + false + + + + org.apache.maven.plugins + maven-javadoc-plugin + 3.3.0 + + ${maven.compiler.source} + false + true + none + false + false + + + + attach-javadocs + + jar + + + + + + org.apache.maven.plugins + maven-resources-plugin + 3.2.0 + + ${project.build.sourceEncoding} + + + + org.apache.maven.plugins + maven-source-plugin + 3.2.1 + + + attach-sources + package + + jar-no-fork + + + + maven-jar-plugin 3.1.1 @@ -206,14 +250,14 @@ maven-surefire-plugin org.apache.maven.plugins - 3.0.0-M3 + 3.0.0-M5 true maven-failsafe-plugin - 3.0.0-M3 + 3.0.0-M5 @@ -244,6 +288,15 @@ + + org.apache.maven.plugins + maven-compiler-plugin + 3.8.1 + + 7 + 7 + + @@ -323,6 +376,16 @@ + + + ossrh + https://oss.sonatype.org/content/repositories/snapshots + + + ossrh + https://oss.sonatype.org/service/local/staging/deploy/maven2/ + + release-sign-artifacts @@ -334,10 +397,21 @@ + + org.sonatype.plugins + nexus-staging-maven-plugin + 1.6.8 + true + + ossrh + https://oss.sonatype.org/ + true + + org.apache.maven.plugins maven-gpg-plugin - 1.4 + 3.0.1 sign-artifacts @@ -348,14 +422,6 @@ - - maven-release-plugin - 2.2.1 - - release-sign-artifacts - clean javadoc:jar source:jar deploy - - diff --git a/readme.txt b/readme.txt deleted file mode 100644 index 0f3bbea..0000000 --- a/readme.txt +++ /dev/null @@ -1,126 +0,0 @@ -JIntellitype Read Me -http://www.melloware.com/ - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. - -Contents --------- -1. Overview -2. Features -3. Installation -4. Quick Usage -5. Acknowledgements -6. Feedback - -1. Overview - -------- - JIntellitype is an API for interacting with Microsoft Intellitype keyboard - commands as well as registering for Global Hotkeys in your application. - The API is a Java JNI library that uses a DLL to do all the communication - with Windows. This library ONLY works on Windows. - - Have you ever wanted to have CTRL+SHIFT+G maximize your Swing application - on the desktop even if that application did not have focus? Now you can by - registering a Windows Hotkey combination your application will be alerted - when the combination you select is pressed anywhere in Windows. - - Have you ever wanted to react to those special Play, Pause, Stop keys on some - Microsoft and Logitech keyboards? Even some laptops now have those special - keys built in and if you want your application to "listen" for them, now you - can! - - -2. Features - -------- - -> Can register global hotkey combinations in Windows - -> Application is notified even if it does not have focus. - -> Can react to those Play, Pause, Stop, Next, Forward Media keys like Winamp - -> Very little code, easy to use API - -> Examples included in JIntellitypeTester.java - -3. Installation - ------------ - - FOR USERS: - -> The 32/64 bit dlls get extracted automatically. - -> Currently does not work on Java 11, probably starting with Java 9. Latest recommended version is - Java 8. - - FOR DEVELOPERS: - -> To build you need Maven 2.0.7 or higher installed from Apache. Just run "mvn package" from the - directory where the pom.xml is located to build the project. - - -> To build the C++ code you need Bloodshed C++ IDE. When you load the .dev project included do not - forget to edit Project->Options and under Directories Tab change the Includes directory to contain - both: - /java5/include - /java5/include/win32 - - Where "java5" is the location of your Java JDK. - - -4. Quick Usage - ------------ - -// Create JIntellitype - ... - JIntellitype.getInstance().addHotKeyListener(new HotKeyListener() {...); - JIntellitype.getInstance().addIntellitypeListener(new IntellitypeListener() {...); - ... - -// 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'); - -// listen for hotkey - public void onHotKey(int aIdentifier) { - if (aIdentifier == 1) - System.out.println("WINDOWS+A hotkey pressed"); - } - } - -// 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; - } - } - -// Termination - ... - JIntellitype.getInstance().cleanUp(); - System.exit(0); - - - -See demo at test/com/melloware/jintellitype/JIntellitypeTester.java for more info.. - -5. Acknowledgements - ---------------- - JIntellitype is distributed with a small number of libraries on which it depends. - Those libraries are: - - -> None currently - -6. Feedback - -------- - Your feedback on JIntellitype (hopefully constructive) is always welcome. Please - visit http://www.melloware.com/ for links to browse and join mailing - lists, file bugs and submit feature requests. - - Also a forum is set up at http://forum.melloware.com/index.php for discussion. diff --git a/src/main/java/com/melloware/jintellitype/HotkeyListener.java b/src/main/java/com/melloware/jintellitype/HotkeyListener.java index fc8d630..8107e44 100644 --- a/src/main/java/com/melloware/jintellitype/HotkeyListener.java +++ b/src/main/java/com/melloware/jintellitype/HotkeyListener.java @@ -31,7 +31,7 @@ * @author Emil A. Lefkof III * @version 1.4.0 * - * @see http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/winui/windowsuserinterface/userinput/keyboardinput/keyboardinputreference/keyboardinputfunctions/registerhotkey.asp + * @see ... */ public interface HotkeyListener { diff --git a/src/main/java/com/melloware/jintellitype/IntellitypeListener.java b/src/main/java/com/melloware/jintellitype/IntellitypeListener.java index f0615f3..e171ea2 100644 --- a/src/main/java/com/melloware/jintellitype/IntellitypeListener.java +++ b/src/main/java/com/melloware/jintellitype/IntellitypeListener.java @@ -36,7 +36,7 @@ * @author Emil A. Lefkof III * @version 1.4.0 * - * @see http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/winui/windowsuserinterface/userinput/keyboardinput/keyboardinputreference/keyboardinputmessages/wm_appcommand.asp + * @see ... */ public interface IntellitypeListener { diff --git a/src/main/java/com/melloware/jintellitype/JIntellitype.java b/src/main/java/com/melloware/jintellitype/JIntellitype.java index 266a85f..04752a7 100644 --- a/src/main/java/com/melloware/jintellitype/JIntellitype.java +++ b/src/main/java/com/melloware/jintellitype/JIntellitype.java @@ -1,4 +1,4 @@ -/** +/* * JIntellitype * ----------------- * Copyright 2005-2019 Emil A. Lefkof III, Melloware Inc. @@ -23,11 +23,7 @@ import java.awt.event.InputEvent; import java.awt.event.KeyEvent; -import java.io.File; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; +import java.io.*; import java.nio.file.Paths; import java.util.Collections; import java.util.HashMap; @@ -97,7 +93,7 @@ public final class JIntellitype implements JIntellitypeConstants { /** * Handler is used by JNI code to keep different JVM instances separate */ - private final long handler = 0; + public final long handler = 0; /** * Map containing key->keycode mapping @@ -139,8 +135,8 @@ private static void loadLibrary() { fromJarToFs("com/melloware/jintellitype/windows/" + libraryName, extractedLibrary.getAbsolutePath()); System.load(extractedLibrary.getAbsolutePath()); } catch (Throwable exAllFailed) { - throw new JIntellitypeException( - "Could not load JIntellitype.dll from local file system or from inside JAR", exAllFailed); + String message = String.format("Could not load JIntellitype.dll from local file system (%s) or from inside JAR.", extractedLibrary.getAbsolutePath()); + throw new JIntellitypeException(message, exAllFailed); } } @@ -169,7 +165,7 @@ private static void fromJarToFs(String jarPath, String filePath) throws IOExcept file.getParentFile().mkdirs(); } - //is = ClassLoader.getSystemClassLoader().getResourceAsStream(jarPath); + is = ClassLoader.getSystemClassLoader().getResourceAsStream(jarPath); os = new FileOutputStream(filePath); byte[] buffer = new byte[8192]; int bytesRead; @@ -259,7 +255,7 @@ public void registerHotKey(int identifier, int modifier, int keycode) { if (modifiers == 0) { modifiers = modifier; } - regHotKey(identifier, modifier, keycode); + regHotKey(identifier, modifiers, keycode); } catch (UnsatisfiedLinkError ex) { throw new JIntellitypeException(ERROR_MESSAGE, ex); } catch (RuntimeException ex) { @@ -387,7 +383,8 @@ public static boolean isJIntellitypeSupported() { protected void onHotKey(final int identifier) { for (final HotkeyListener hotkeyListener : hotkeyListeners) { SwingUtilities.invokeLater(new Runnable() { - public void run() { + @Override + public void run() { hotkeyListener.onHotKey(identifier); } }); @@ -402,7 +399,8 @@ public void run() { protected void onIntellitype(final int command) { for (final IntellitypeListener intellitypeListener : intellitypeListeners) { SwingUtilities.invokeLater(new Runnable() { - public void run() { + @Override + public void run() { intellitypeListener.onIntellitype(command); } }); @@ -446,7 +444,7 @@ protected static int swingToIntelliType(int swingKeystrokeModifier) { * use all keys specified here instead of just [A-Z],[0-9] as before */ private HashMap getKey2KeycodeMapping() { - HashMap map = new HashMap(); + HashMap map = new HashMap<>(); map.put("first", KeyEvent.KEY_FIRST); map.put("last", KeyEvent.KEY_LAST); diff --git a/src/main/java/com/melloware/jintellitype/JIntellitypeConstants.java b/src/main/java/com/melloware/jintellitype/JIntellitypeConstants.java index 36c254c..f418729 100644 --- a/src/main/java/com/melloware/jintellitype/JIntellitypeConstants.java +++ b/src/main/java/com/melloware/jintellitype/JIntellitypeConstants.java @@ -1,4 +1,4 @@ -/** +/* * JIntellitype * ----------------- * Copyright 2005-2019 Emil A. Lefkof III, Melloware Inc. @@ -33,29 +33,29 @@ */ public interface JIntellitypeConstants { - public static final String ERROR_MESSAGE = "JIntellitype DLL Error"; + String ERROR_MESSAGE = "JIntellitype DLL Error"; // Modifier keys, can be added together /** * ALT key for registering Hotkeys. */ - public static final int MOD_ALT = 1; + int MOD_ALT = 1; /** * CONTROL key for registering Hotkeys. */ - public static final int MOD_CONTROL = 2; + int MOD_CONTROL = 2; /** * SHIFT key for registering Hotkeys. */ - public static final int MOD_SHIFT = 4; + int MOD_SHIFT = 4; /** * WINDOWS key for registering Hotkeys. */ - public static final int MOD_WIN = 8; + int MOD_WIN = 8; // Intellitype Virtual Key Constants from MSDN @@ -63,119 +63,119 @@ public interface JIntellitypeConstants { /** * Browser Navigate backward */ - public static final int APPCOMMAND_BROWSER_BACKWARD = 1; + int APPCOMMAND_BROWSER_BACKWARD = 1; /** * Browser Navigate forward */ - public static final int APPCOMMAND_BROWSER_FORWARD = 2; + int APPCOMMAND_BROWSER_FORWARD = 2; /** * Browser Refresh page */ - public static final int APPCOMMAND_BROWSER_REFRESH = 3; + int APPCOMMAND_BROWSER_REFRESH = 3; /** * Browser Stop download */ - public static final int APPCOMMAND_BROWSER_STOP = 4; + int APPCOMMAND_BROWSER_STOP = 4; /** * Browser Open search */ - public static final int APPCOMMAND_BROWSER_SEARCH = 5; + int APPCOMMAND_BROWSER_SEARCH = 5; /** * Browser Open favorites */ - public static final int APPCOMMAND_BROWSER_FAVOURITES = 6; + int APPCOMMAND_BROWSER_FAVOURITES = 6; /** * Browser Navigate home */ - public static final int APPCOMMAND_BROWSER_HOME = 7; + int APPCOMMAND_BROWSER_HOME = 7; /** * Mute the volume */ - public static final int APPCOMMAND_VOLUME_MUTE = 8; + int APPCOMMAND_VOLUME_MUTE = 8; /** * Lower the volume */ - public static final int APPCOMMAND_VOLUME_DOWN = 9; + int APPCOMMAND_VOLUME_DOWN = 9; /** * Raise the volume */ - public static final int APPCOMMAND_VOLUME_UP = 10; + int APPCOMMAND_VOLUME_UP = 10; /** * Media application go to next track. */ - public static final int APPCOMMAND_MEDIA_NEXTTRACK = 11; + int APPCOMMAND_MEDIA_NEXTTRACK = 11; /** * Media application Go to previous track. */ - public static final int APPCOMMAND_MEDIA_PREVIOUSTRACK = 12; + int APPCOMMAND_MEDIA_PREVIOUSTRACK = 12; /** * Media application Stop playback. */ - public static final int APPCOMMAND_MEDIA_STOP = 13; + int APPCOMMAND_MEDIA_STOP = 13; /** * Media application Play or pause playback. */ - public static final int APPCOMMAND_MEDIA_PLAY_PAUSE = 14; + int APPCOMMAND_MEDIA_PLAY_PAUSE = 14; /** * Open mail application */ - public static final int APPCOMMAND_LAUNCH_MAIL = 15; + int APPCOMMAND_LAUNCH_MAIL = 15; /** * Go to Media Select mode. */ - public static final int APPCOMMAND_LAUNCH_MEDIA_SELECT = 16; + int APPCOMMAND_LAUNCH_MEDIA_SELECT = 16; /** * Start App1. */ - public static final int APPCOMMAND_LAUNCH_APP1 = 17; + int APPCOMMAND_LAUNCH_APP1 = 17; /** * Start App2. */ - public static final int APPCOMMAND_LAUNCH_APP2 = 18; - - public static final int APPCOMMAND_BASS_DOWN = 19; - public static final int APPCOMMAND_BASS_BOOST = 20; - public static final int APPCOMMAND_BASS_UP = 21; - public static final int APPCOMMAND_TREBLE_DOWN = 22; - public static final int APPCOMMAND_TREBLE_UP = 23; - public static final int APPCOMMAND_MICROPHONE_VOLUME_MUTE = 24; - public static final int APPCOMMAND_MICROPHONE_VOLUME_DOWN = 25; - public static final int APPCOMMAND_MICROPHONE_VOLUME_UP = 26; - public static final int APPCOMMAND_HELP = 27; - public static final int APPCOMMAND_FIND = 28; - public static final int APPCOMMAND_NEW = 29; - public static final int APPCOMMAND_OPEN = 30; - public static final int APPCOMMAND_CLOSE = 31; - public static final int APPCOMMAND_SAVE = 32; - public static final int APPCOMMAND_PRINT = 33; - public static final int APPCOMMAND_UNDO = 34; - public static final int APPCOMMAND_REDO = 35; - public static final int APPCOMMAND_COPY = 36; - public static final int APPCOMMAND_CUT = 37; - public static final int APPCOMMAND_PASTE = 38; - public static final int APPCOMMAND_REPLY_TO_MAIL = 39; - public static final int APPCOMMAND_FORWARD_MAIL = 40; - public static final int APPCOMMAND_SEND_MAIL = 41; - public static final int APPCOMMAND_SPELL_CHECK = 42; - public static final int APPCOMMAND_DICTATE_OR_COMMAND_CONTROL_TOGGLE = 43; - public static final int APPCOMMAND_MIC_ON_OFF_TOGGLE = 44; - public static final int APPCOMMAND_CORRECTION_LIST = 45; + int APPCOMMAND_LAUNCH_APP2 = 18; + + int APPCOMMAND_BASS_DOWN = 19; + int APPCOMMAND_BASS_BOOST = 20; + int APPCOMMAND_BASS_UP = 21; + int APPCOMMAND_TREBLE_DOWN = 22; + int APPCOMMAND_TREBLE_UP = 23; + int APPCOMMAND_MICROPHONE_VOLUME_MUTE = 24; + int APPCOMMAND_MICROPHONE_VOLUME_DOWN = 25; + int APPCOMMAND_MICROPHONE_VOLUME_UP = 26; + int APPCOMMAND_HELP = 27; + int APPCOMMAND_FIND = 28; + int APPCOMMAND_NEW = 29; + int APPCOMMAND_OPEN = 30; + int APPCOMMAND_CLOSE = 31; + int APPCOMMAND_SAVE = 32; + int APPCOMMAND_PRINT = 33; + int APPCOMMAND_UNDO = 34; + int APPCOMMAND_REDO = 35; + int APPCOMMAND_COPY = 36; + int APPCOMMAND_CUT = 37; + int APPCOMMAND_PASTE = 38; + int APPCOMMAND_REPLY_TO_MAIL = 39; + int APPCOMMAND_FORWARD_MAIL = 40; + int APPCOMMAND_SEND_MAIL = 41; + int APPCOMMAND_SPELL_CHECK = 42; + int APPCOMMAND_DICTATE_OR_COMMAND_CONTROL_TOGGLE = 43; + int APPCOMMAND_MIC_ON_OFF_TOGGLE = 44; + int APPCOMMAND_CORRECTION_LIST = 45; } diff --git a/src/main/java/com/melloware/jintellitype/JIntellitypeException.java b/src/main/java/com/melloware/jintellitype/JIntellitypeException.java index 7b04500..da745b9 100644 --- a/src/main/java/com/melloware/jintellitype/JIntellitypeException.java +++ b/src/main/java/com/melloware/jintellitype/JIntellitypeException.java @@ -1,4 +1,4 @@ -/** +/* * JIntellitype * ----------------- * Copyright 2005-2019 Emil A. Lefkof III, Melloware Inc. diff --git a/src/main/java/com/melloware/jintellitype/Main.java b/src/main/java/com/melloware/jintellitype/Main.java index 3044daf..44f1fde 100644 --- a/src/main/java/com/melloware/jintellitype/Main.java +++ b/src/main/java/com/melloware/jintellitype/Main.java @@ -1,4 +1,4 @@ -/** +/* * JIntellitype * ----------------- * Copyright 2005-2019 Emil A. Lefkof III, Melloware Inc. diff --git a/src/main/resources/com/melloware/jintellitype/windows/JIntellitype.dll b/src/main/resources/com/melloware/jintellitype/windows/JIntellitype.dll index 839236b..54a2333 100644 Binary files a/src/main/resources/com/melloware/jintellitype/windows/JIntellitype.dll and b/src/main/resources/com/melloware/jintellitype/windows/JIntellitype.dll differ diff --git a/src/main/resources/com/melloware/jintellitype/windows/JIntellitype64.dll b/src/main/resources/com/melloware/jintellitype/windows/JIntellitype64.dll index 6dc2680..c7b789b 100644 Binary files a/src/main/resources/com/melloware/jintellitype/windows/JIntellitype64.dll and b/src/main/resources/com/melloware/jintellitype/windows/JIntellitype64.dll differ