Results 1 to 6 of 6
  1. #1
    alexburkee is offline Member
    Join Date
    Dec 2011
    Posts
    6
    Rep Power
    0

    Default 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.

    Java Code:
    import java.awt.Robot;
    
    public class Main {
      public static void main(String[] argv) throws Exception {
        Robot robot = new Robot();
        robot.mouseMove(,);
      }
    }
    I want to add

    Java 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

    Java 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 :)

  2. #2
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,321
    Rep Power
    25

    Default Re: RNG Used To Move Mouse

    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.
    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

  3. #3
    alexburkee is offline Member
    Join Date
    Dec 2011
    Posts
    6
    Rep Power
    0

    Default Re: RNG Used To Move Mouse

    I still have not figured it out.. more help is appreciated

  4. #4
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,321
    Rep Power
    25

    Default 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.

  5. #5
    alexburkee is offline Member
    Join Date
    Dec 2011
    Posts
    6
    Rep Power
    0

    Default 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$

  6. #6
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,321
    Rep Power
    25

    Default Re: RNG Used To Move Mouse

    Come on back if you need help while you are writing your program.

Similar Threads

  1. JButton doesnt show unless you move mouse over it
    By liluma in forum AWT / Swing
    Replies: 4
    Last Post: 12-06-2011, 03:33 AM
  2. Replies: 9
    Last Post: 06-17-2011, 05:10 AM
  3. how to move an image automatically without using mouse
    By saranyabaskaran in forum New To Java
    Replies: 6
    Last Post: 03-19-2011, 10:00 AM
  4. Mouse Listener for mouse floating over object?
    By Krooger in forum AWT / Swing
    Replies: 1
    Last Post: 11-18-2009, 04:34 AM
  5. Replies: 1
    Last Post: 10-30-2009, 06:47 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •