I tried to post a new native key pressing to the system using the java library https://github.com/kwhat/jnativehook. The method
GlobalScreen.postNativeEvent();
Needs to get passed a NativeInputEvent object, which needs the Parameters
- An instance of Global Screen
- Two integers and one long
Based on the documentation I can’t figure out what the required parameters are and how to for example initialize a new GlobalScreen object. (https://github.com/kwhat/jnativehook/blob/master/src/java/org/jnativehook/NativeInputEvent.java)
Thanks for answers in advance!
Advertisement
Answer
With the help of the developer I solved the question. To post media key events to the system using jnativehook you can use the following code:
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)); }