I'd like to type: "/ammo" when I type ALT+A. The program runs but it seems like to stop right after the running: I press alt+A or A and the code is not doing anything at all.
package jnativehook01;
import java.awt.AWTException;
import java.awt.Robot;
import java.awt.Toolkit;
import java.awt.datatransfer.Clipboard;
import java.awt.datatransfer.StringSelection;
import java.awt.event.KeyEvent;
import org.jnativehook.GlobalScreen;
import org.jnativehook.NativeHookException;
import org.jnativehook.keyboard.NativeKeyEvent;
import org.jnativehook.keyboard.NativeKeyListener;
public class Example implements NativeKeyListener {
    public void nativeKeyPressed(NativeKeyEvent e) {
        if (NativeKeyEvent.getKeyText(e.getKeyCode()).equals("A")) {
            try {
                GlobalScreen.unregisterNativeHook();
                Robot bot;
                try {
                    bot = new Robot();
                    String text = "/ammo";
                     StringSelection stringSelection = new StringSelection(text);
                     Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
                     clipboard.setContents(stringSelection, stringSelection);
                    //type: /ammo
                    bot.keyPress(KeyEvent.VK_T);
                    bot.keyRelease(KeyEvent.VK_T);
                } catch (AWTException e1) {
                }
            } catch (NativeHookException e1) {
            }
        }
    }
    public void nativeKeyReleased(NativeKeyEvent e) {
        System.out.println("Key Released: " + NativeKeyEvent.getKeyText(e.getKeyCode()));
    }
    public void nativeKeyTyped(NativeKeyEvent e) {
        System.out.println("Key Typed: " + e.getKeyText(e.getKeyCode()));
    }
    public static void main(String[] args) {
        new Example();
    }
}
 
                        
Ok, now it's working: