Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 3 of 3

Thread: Auto Clicker Problems!

  1. #1
    Junior Member
    Join Date
    Jan 2014
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Auto Clicker Problems!

    Hello everyone,

    I am trying to create a program that clicks a desired amount of clicks after one second intervals. My code doesn't seem to be doing what I want it to do thus far. Here it is:

    import java.lang.Object.*;
    import java.awt.AWTException;
    import java.awt.Robot;
    import java.awt.event.InputEvent;
    import javax.swing.*;

    public class MainClass {

    public static int numClicks = 0;
    public static int numDesiredClicks = 0;


    public static void main(String[] args) throws Exception {


    getDesiredClicks();
    Robot robot = new Robot();
    if(numClicks<numDesiredClicks)
    {
    robot.mousePress(InputEvent.BUTTON1_MASK);
    robot.delay(500);
    robot.mouseRelease(InputEvent.BUTTON1_MASK);
    robot.delay(1000);
    numClicks++;
    }

    }


    public static void getDesiredClicks()
    {
    numDesiredClicks = Prompter.promptForInteger("How many clicks should be performed?");
    }

    }


  2. #2
    Super Moderator
    Join Date
    Jun 2013
    Location
    So. Maryland, USA
    Posts
    5,295
    My Mood
    Mellow
    Thanks
    193
    Thanked 669 Times in 656 Posts

    Default Re: Auto Clicker Problems!

    Welcome to the Forum! Please read this topic to learn how to post your code correctly along with other useful info for newcomers.

    You should consider using a Timer to do what you have in mind, in this case the java.util.Timer.

  3. #3
    Member andbin's Avatar
    Join Date
    Dec 2013
    Location
    Italy
    Posts
    443
    Thanks
    4
    Thanked 122 Times in 114 Posts

    Default Re: Auto Clicker Problems!

    Quote Originally Posted by Mr Stunnaa View Post
    I am trying to create a program that clicks a desired amount of clicks after one second intervals.
    If this is all what the main() should do sequentially, then after the user input it's sufficient to create a loop using appropriate "delays" (technically robot.delay() or Thread.sleep() methods) to get one second intervals.
    Andrea, www.andbin.net SCJP 5 (91%) SCWCD 5 (94%)

    Useful links for Java beginners My new project Java Examples on Google Code

Similar Threads

  1. Auto Select
    By _lithium_ in forum What's Wrong With My Code?
    Replies: 14
    Last Post: May 31st, 2011, 04:55 AM
  2. Auto contrast and auto brightness
    By oxxxis in forum Java Theory & Questions
    Replies: 0
    Last Post: January 21st, 2010, 02:00 PM

Tags for this Thread