Advertisement
Steezy

SmartRobot (Typer)

Aug 12th, 2012
45
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.56 KB | None | 0 0
  1. import java.awt.AWTException;
  2. import java.awt.Robot;
  3. import java.awt.event.KeyEvent;
  4.  
  5. public class SmartRobot extends Robot {
  6.  
  7.  public SmartRobot() throws AWTException {
  8.   super();
  9.  }
  10.  
  11.  public void keyType(int keyCode) {
  12.   keyPress(keyCode);
  13.   delay(1);
  14.   keyRelease(keyCode);
  15.  }
  16.  
  17.  
  18.  public void type(String text) {
  19.   String textUpper = text.toUpperCase();
  20.  
  21.   for (int i=0; i<text.length(); ++i) {
  22.    typeChar(textUpper.charAt(i));
  23.   }  
  24.  }
  25.  
  26.  private void typeChar(char c) {
  27.  
  28.   int keyCode;
  29.   keyCode = (int)c;
  30.  
  31.    keyType(keyCode);
  32.  }
  33.  
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement