vendredi 8 mai 2015

Using Robot Class and Random Class (Java)

i have a project with Database so i was thinking that i can create a program-like bot to fill the Database with some random numbers and names faster instead of writing ... here's the code tho its not completed cuz i tried to write numbers from 1 to 600 and it didnt work so i didnt complete the code ... i know that the problem is with the character array but have no idea how to fix it =D

import java.awt.AWTException;
import java.awt.Robot;
import java.awt.event.KeyEvent;
import java.util.Random;
public class Main{
    public static void main(String[] args){
        Random rand = new Random();
        String holder;
        String firstName[]={};
        String secondName[]={};
        try{
            Robot robot = new Robot();
                 robot.delay(4000);
                     for(int i =1;i<=600;i++){
                holder = Integer.toString(i);
                char arraychr[] = holder.toCharArray();
                    robot.keyPress(arraychr[i]);
                robot.keyPress(KeyEvent.VK_DOWN);
                     }
        }
        catch(AWTException e){
            e.printStackTrace();
        }
    }
}




Aucun commentaire:

Enregistrer un commentaire