该方法仅适用于windows系统,后台响应全局快捷键操作的意思是java应用程序失去焦点(比如最小化或置于系统托盘)情况下,仍能响应用户的快捷键操作。
1、下载jintellitype
它是一个JNI调用Windows系统接口的工具包,下载地址:Google搜索或 http://download.youkuaiyun.com/detail/linxcool/7750191
2、拷贝资源到你的工作空间
以下仅供参考:
3、添加对jintellitype-1.x.x.jar的引用
4、编码实现
a、实现HotkeyListener,、IntellitypeListener接口
b、设置dll目录并检查其运行情况
JIntellitype.setLibraryLocation(libPath);
if (JIntellitype.checkInstanceAlreadyRunning("你的窗体标题")) {
System.exit(1);
}
if (!JIntellitype.isJIntellitypeSupported()) {
System.exit(1);
}
c、注册快捷键JIntellitype.getInstance().registerHotKey(自定义intA数据, JIntellitype.MOD_ALT, 'A');
以上注册了ALT+A的快捷监听
d、在onHotKey(int identifier)中处理监听