public class Main {
/**
* @param args
* @throws FileNotFoundException
* @throws AWTException
*/
public static void main(String[] args) throws FileNotFoundException, AWTException {
Robot robot;
robot = new Robot();
while(true)
{
robot.delay(3000);
robot.keyPress(KeyEvent.VK_V);
robot.keyRelease(KeyEvent.VK_V);
robot.keyPress(KeyEvent.VK_ENTER);
robot.keyRelease(KeyEvent.VK_ENTER);
}
}
}
将这段小代码搭成jar包,后我远程登录一台没有显示器的电脑,把jar包拷到这台没有显示器的电脑上,运行jar,并将鼠标焦点指到文本文件上,想每隔3秒输入一个v,一个回车。
我远程登录的时候,能正确运行,但是我退出登录,jar包程序还会运行,但是没有输出了。
robot控制鼠标键盘必须在有显示器的电脑上才能运行吗?