|
@@ -0,0 +1,72 @@
|
|
|
|
+package me.yoqi.mRobot;
|
|
|
|
+
|
|
|
|
+import java.awt.AWTException;
|
|
|
|
+import java.awt.Robot;
|
|
|
|
+import java.awt.event.KeyEvent;
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ * 键盘自动输入helloworld
|
|
|
|
+ * @author liuyuqi
|
|
|
|
+ *
|
|
|
|
+ */
|
|
|
|
+public class TestHelloWorld {
|
|
|
|
+ private static Robot robot;
|
|
|
|
+
|
|
|
|
+ public void test() throws AWTException{
|
|
|
|
+ helloWorld();
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ * @throws AWTException
|
|
|
|
+ */
|
|
|
|
+ public void helloWorld() throws AWTException{
|
|
|
|
+ robot=new Robot();
|
|
|
|
+
|
|
|
|
+ robot.delay(5000);
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ robot.keyPress(KeyEvent.VK_CAPS_LOCK);
|
|
|
|
+ robot.keyRelease(KeyEvent.VK_CAPS_LOCK);
|
|
|
|
+ robot.delay(500);
|
|
|
|
+ robot.keyPress(KeyEvent.VK_H);
|
|
|
|
+ robot.keyRelease(KeyEvent.VK_H);
|
|
|
|
+ robot.delay(200);
|
|
|
|
+ robot.keyPress(KeyEvent.VK_CAPS_LOCK);
|
|
|
|
+ robot.keyRelease(KeyEvent.VK_CAPS_LOCK);
|
|
|
|
+ robot.delay(200);
|
|
|
|
+ robot.keyPress(KeyEvent.VK_E);
|
|
|
|
+ robot.keyRelease(KeyEvent.VK_E);
|
|
|
|
+ robot.delay(200);
|
|
|
|
+ robot.keyPress(KeyEvent.VK_L);
|
|
|
|
+ robot.keyRelease(KeyEvent.VK_L);
|
|
|
|
+ robot.delay(200);
|
|
|
|
+ robot.keyPress(KeyEvent.VK_L);
|
|
|
|
+ robot.keyRelease(KeyEvent.VK_L);
|
|
|
|
+ robot.delay(200);
|
|
|
|
+ robot.keyPress(KeyEvent.VK_O);
|
|
|
|
+ robot.keyRelease(KeyEvent.VK_O);
|
|
|
|
+ robot.delay(200);
|
|
|
|
+ robot.keyPress(KeyEvent.VK_CAPS_LOCK);
|
|
|
|
+ robot.keyRelease(KeyEvent.VK_CAPS_LOCK);
|
|
|
|
+ robot.delay(200);
|
|
|
|
+ robot.keyPress(KeyEvent.VK_W);
|
|
|
|
+ robot.keyRelease(KeyEvent.VK_W);
|
|
|
|
+ robot.delay(200);
|
|
|
|
+ robot.keyPress(KeyEvent.VK_CAPS_LOCK);
|
|
|
|
+ robot.keyRelease(KeyEvent.VK_CAPS_LOCK);
|
|
|
|
+ robot.delay(200);
|
|
|
|
+ robot.keyPress(KeyEvent.VK_O);
|
|
|
|
+ robot.keyRelease(KeyEvent.VK_O);
|
|
|
|
+ robot.delay(200);
|
|
|
|
+ robot.keyPress(KeyEvent.VK_R);
|
|
|
|
+ robot.keyRelease(KeyEvent.VK_R);
|
|
|
|
+ robot.delay(200);
|
|
|
|
+ robot.keyPress(KeyEvent.VK_L);
|
|
|
|
+ robot.keyRelease(KeyEvent.VK_L);
|
|
|
|
+ robot.delay(200);
|
|
|
|
+ robot.keyPress(KeyEvent.VK_D);
|
|
|
|
+ robot.keyRelease(KeyEvent.VK_D);
|
|
|
|
+ robot.delay(200);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+}
|