JNativeHook Post 原生按键事件

JNativeHook Post a native key event

我尝试 post 使用 java 库 https://github.com/kwhat/jnativehook 向系统按下新的本地键。 方法

GlobalScreen.postNativeEvent();

需要传递一个 NativeInputEvent 对象,它需要参数

根据文档,我无法弄清楚所需的参数是什么以及如何初始化新的 GlobalScreen 对象。 (https://github.com/kwhat/jnativehook/blob/master/src/java/org/jnativehook/NativeInputEvent.java)

提前感谢您的回答!

With the help of the developer 我解决了这个问题。要post media key events to the system using jnativehook 你可以使用下面的代码:

public static void MediaKeyForward(){
    GlobalScreen.postNativeEvent(new NativeKeyEvent(2401,0,176,57369,org.jnativehook.keyboard.NativeKeyEvent.CHAR_UNDEFINED));

}
public static void MediaKeyBack(){
    GlobalScreen.postNativeEvent(new NativeKeyEvent(2401,0,177,57360,org.jnativehook.keyboard.NativeKeyEvent.CHAR_UNDEFINED));

}
public static void MediaKeyPause(){
 GlobalScreen.postNativeEvent(new NativeKeyEvent(2401,0,179,57378,org.jnativehook.keyboard.NativeKeyEvent.CHAR_UNDEFINED));

}