# RNG Used To Move Mouse

• 12-10-2011, 11:09 PM
alexburkee
RNG Used To Move Mouse
Alright so I am new here and new to Java but I want to create a simple java program used to
control the mouse randomly and click randomly.. I have been searching for hours and I can only find
some code that will help me.

Code:

```import java.awt.Robot; public class Main {   public static void main(String[] argv) throws Exception {     Robot robot = new Robot();     robot.mouseMove(,);   } }```

Code:

`import java.util.Random;`
I have this code and been trying to mess around with it to see if It can take the highest value after the generation and make the mouse move

Code:

```    Random randomNumbers = new Random(); // random number generator       int MoveUp = 0; // count of Ups rolled       int MoveDown = 0; // count of Downs rolled       int Moveright = 0; // count of Rights rolled       int MoveLeft = 0; // count of Lefts rolled       int face; // stores value?         for ( int roll = 1; roll <= 6000; roll++ )       {         face = 1 + randomNumbers.nextInt( 6 ); // number from 1 to 6           // determine roll value 1-6 and increment appropriate counter         switch ( face )         {              case 1:               ++MoveUp; // increment the ups counter               break;             case 2:               ++MoveDown; // increment the downs counter               break;             case 3:               ++Moveright; // increment the rights counter               break;             case 4:               ++MoveLeft; // increment the lefts counter               break;         }       }```
Im stuck now.
How can I make the java program take the highest value out of the 4. Then move the mouse in that direction then "Break" for a few seconds then do it again.
Any help is appreciated :)
• 12-10-2011, 11:44 PM
Norm
Re: RNG Used To Move Mouse
Quote:

How can I make the java program take the highest value out of the 4.
You could sort the values to get the highest one.
Quote:

move the mouse in that direction then "Break" for a few seconds
If you have no other use for the CPU, you could use the Thead sleep method to wait for a few seconds.
If you want to do other things while you wait, use a Timer class to call your 'move the mouse' code every few seconds
• 12-12-2011, 12:03 AM
alexburkee
Re: RNG Used To Move Mouse
I still have not figured it out.. more help is appreciated
• 12-12-2011, 12:05 AM
Norm
Re: RNG Used To Move Mouse
What is the "it" that you are working on?
1) take the highest value after the generation
2) make the mouse move
3)Break" for a few seconds
4)then do it again.

Pick one and work on that one until it does what you want and then move to the next one.
• 12-12-2011, 12:32 AM
alexburkee
Re: RNG Used To Move Mouse
Its for researching the randomness of the generators.
So basically I need a program that will move up when there are more up's generated out of about 1000 random generations.

I am contemplating on hiring a programmer to do this for me off of a website but there price for something like this is about 100-150\$
• 12-12-2011, 12:36 AM
Norm
Re: RNG Used To Move Mouse
Come on back if you need help while you are writing your program.