import java.awt.Robot;
import java.awt.event.KeyEvent;
public class Main {
static boolean check = false;
static boolean boom = true;
public static void main(String[] args) throws Exception{
do{
if(check == true){
Robot r = new Robot();
r.delay(1000);
r.keyPress(KeyEvent.VK_DECIMAL);
r.keyRelease(KeyEvent.VK_DECIMAL);
r.keyPress(KeyEvent.VK_M);
r.keyRelease(KeyEvent.VK_M);
r.keyPress(KeyEvent.VK_E);
r.keyRelease(KeyEvent.VK_E);
r.keyPress(KeyEvent.VK_N);
r.keyRelease(KeyEvent.VK_N);
r.keyPress(KeyEvent.VK_U);
r.keyRelease(KeyEvent.VK_U);
r.keyPress(KeyEvent.VK_ENTER);
r.keyRelease(KeyEvent.VK_ENTER);
}
}while(boom == true);
}
public void keyPressed(KeyEvent e){
int keyCode = e.getKeyCode();
if(keyCode == KeyEvent.VK_F9){
check = true;
boom = true;
}
if(keyCode == KeyEvent.VK_F11){
check = false;
boom = false;
}
}
}
This is my code,I want it work like this: When you press F9 it should start write .menu and when pressing F11 it should stop. Any Help?