package li.x1ang.jautomaiton;

import java.awt.AWTException;
import java.awt.Robot;

/**
 * @author x1ang.li
 * 
 * I got a coupon 
 *
 */
public class MiniKeyTyper {
    private final String PREFIX = "f384";
    private final String SUFFIX = "764663c81d1";
    private final int BREAK_TIME = 4 * 1000; // You need to take a break between each iteration to do something like clicking the "Confirm" button and suppress error messages.    

    private Robot robot;
    
	public MiniKeyTyper() throws AWTException {
		robot = new Robot();
	}

	public void run() {
		System.out.println("I am running");
		robot.delay(3000);
		for (int i=0; i<=9; i++) {
		    string code_i = PREFIX + i + SUFFIX
			System.out.println("We are about to type the code:" + code_i);
			type(code_i);
			robot.delay(BREAK_TIME);
		}
		System.out.println("I am finished running.");
	}
	
	private void type(String s) {
		byte[] bytes = s.getBytes();
		for (byte b : bytes) {
			int code = b;
			
			// keycode handles [A-Z] (which is ASCII decimal [65-90])
			if (code > 96 && code < 123)
				code = code - 32;
				
			robot.delay(40);
			robot.keyPress(code);
			robot.keyRelease(code);
		}
	}

	public static void main(String[] args) {
		MiniKeyTyper main;
		try {
			main = new MiniKeyTyper();
			main.run();
		} catch (AWTException e) {
			e.printStackTrace();
		}
	}

}

@@ -462,17 +462,20 @@
 t;%0A    %0A
-%09
+    
 public M
@@ -510,18 +510,24 @@
 ption %7B%0A
-%09%09
+        
 robot = 
@@ -539,21 +539,27 @@
 obot();%0A
-%09%7D%0A%0A%09
+    %7D%0A%0A    
 public v
@@ -570,18 +570,24 @@
 run() %7B%0A
-%09%09
+        
 System.o
@@ -614,18 +614,24 @@
 ning%22);%0A
-%09%09
+        
 robot.de
@@ -641,18 +641,24 @@
 (3000);%0A
-%09%09
+        
 for (int
@@ -676,18 +676,24 @@
  i++) %7B%0A
-%09%09
+        
     stri
@@ -724,19 +724,28 @@
  SUFFIX%0A
-%09%09%09
+            
 System.o
@@ -799,19 +799,28 @@
 ode_i);%0A
-%09%09%09
+            
 type(cod
@@ -825,19 +825,28 @@
 ode_i);%0A
-%09%09%09
+            
 robot.de
@@ -866,14 +866,26 @@
 E);%0A
-%09%09%7D%0A%09%09
+        %7D%0A        
 Syst
@@ -930,14 +930,23 @@
 %22);%0A
-%09%7D%0A%09%0A%09
+    %7D%0A    %0A    
 priv
@@ -971,18 +971,24 @@
 ng s) %7B%0A
-%09%09
+        
 byte%5B%5D b
@@ -1008,18 +1008,24 @@
 ytes();%0A
-%09%09
+        
 for (byt
@@ -1039,19 +1039,28 @@
 ytes) %7B%0A
-%09%09%09
+            
 int code
@@ -1065,23 +1065,41 @@
 de = b;%0A
-%09%09%09%0A%09%09%09
+            %0A            
 // keyco
@@ -1148,19 +1148,28 @@
 65-90%5D)%0A
-%09%09%09
+            
 if (code
@@ -1189,20 +1189,32 @@
  %3C 123)%0A
-%09%09%09%09
+                
 code = c
@@ -1227,16 +1227,37 @@
 32;%0A
-%09%09%09%09%0A%09%09%09
+                %0A            
 robo
@@ -1269,19 +1269,28 @@
 ay(40);%0A
-%09%09%09
+            
 robot.ke
@@ -1303,19 +1303,28 @@
 (code);%0A
-%09%09%09
+            
 robot.ke
@@ -1343,17 +1343,29 @@
 e);%0A
-%09%09%7D%0A%09%7D%0A%0A%09
+        %7D%0A    %7D%0A%0A    
 publ
@@ -1401,18 +1401,24 @@
 args) %7B%0A
-%09%09
+        
 MiniKeyT
@@ -1432,19 +1432,34 @@
 in;%0A
-%09%09try %7B%0A%09%09%09
+        try %7B%0A            
 main
@@ -1481,19 +1481,28 @@
 yper();%0A
-%09%09%09
+            
 main.run
@@ -1505,18 +1505,24 @@
 .run();%0A
-%09%09
+        
 %7D catch 
@@ -1544,11 +1544,20 @@
 ) %7B%0A
-%09%09%09
+            
 e.pr
@@ -1577,13 +1577,22 @@
 ();%0A
-%09%09%7D%0A%09
+        %7D%0A    
 %7D%0A%0A%7D

Update MiniKeyTyper.java