java.awt.Robot

 1 import java.awt.AWTException;
 2 import java.awt.Robot;
 3 import java.awt.event.KeyEvent;
 4 
 5 public class TestRobot {
 6     Robot man;
 7 
 8     public static void main(String[] args) throws AWTException {
 9         new TestRobot();
10     }
11 
12     public TestRobot() throws AWTException {
13         man = new Robot();
14         man.mouseMove(300, 300);
15         String s = "weidwiao is great";
16         int k = KeyEvent.VK_A;
17         for (char i : s.toCharArray()) {
18             if (Character.isAlphabetic(i))
19                 i = Character.toUpperCase(i);
20             else if(Character.isSpaceChar(i))
21                 i=KeyEvent.VK_SPACE; 
22             man.keyPress(i);
23             man.keyRelease(i);
24             man.delay(1000);
25         }
26     }
27 }
原文地址:https://www.cnblogs.com/weiyinfu/p/4958637.html