如果要从JNativeHook删除该日志垃圾邮件:
// Clear previous logging configurations.
LogManager.getLogManager().reset();
// Get the logger for "org.jnativehook" and set the level to off.
Logger logger = Logger.getLogger(GlobalScreen.class.getPackage().getName());
logger.setLevel(Level.OFF);
例如,将其添加到.您的主类构造带有remove(几乎)所有日志记录.
现在,让我们自己检测事件并打印一些基本信息.
首先,您必须注册NativeHook:
GlobalScreen.registerNativeHook();
然后将一些监听器绑定到它,例如:
GlobalScreen.getInstance().addNativeKeyListener(new YourMainClass());
然后像这样重写JNativeHook事件方法:
@Override
public void nativeKeyPressed(NativeKeyEvent e) {
System.out.Println(((char) e.getKeyCode()) + " was pressed.")
}
签出:JNativeHook GitHub,您将找到一些示例代码(例如Global Mouse Listener和有关其事件的文档.