How to create Simple Auto Clicker

How to Create Simple Auto Clicker
Share this to your friends

Auto clicker are software designed to do a certain job, to automatically click. Controlling mouse click automatically is sometimes needed to make task easier. Like surfing sites in traffic exchange websites, boosting character experience in games, or just simply making your clash of clans village online for a long period of time to avoid being attacked (in case your using your desktop computer to play such game). I’m designing this auto clicker to achieve easiness in these certain task, so if you need to do much complicated jobs, you need to adjust the software to fulfill your needs.

Creating Auto Clicker using Microsoft Visual Studio

  • Create a new project in Visual Studio
  • Select Visual C#, Windows Form Application in the New Project form
  • And design your form exactly what the image shows

ProEsc Auto Clicker

Designing the software as simple as possible to focus on the most important function of the application.

  • option to set time interval
  • a simple label that shows the current status of the application
  • a start button that checks for a valid time interval and triggers the mouse click event
  • and a stop button that resets the form and stops the timer

Windows Form Auto Clicker Code


using System;
using System.Windows.Forms;
using System.Runtime.InteropServices;

namespace ProEsc_AutoClicker {
      public partial class Main : Form {
      // declare a function residing in the user32.dll, this is the function needed to control mouse event
      [DllImport("user32.dll", CharSet = CharSet.Auto, CallingConvention = CallingConvention.StdCall)]
      public static extern void mouse_event(uint dwFlags, uint dx, uint dy, uint cButtons, uint dwExtraInfo);

      // declare variables and initialize its value
      private const int MOUSEEVENTF_LEFTDOWN = 0x02;
      private const int MOUSEEVENTF_LEFTUP = 0x04;
      private int X = Cursor.Position.X;
      private int Y = Cursor.Position.Y;

      // initialize a new instance of the timer class
      Timer timer = new Timer();

      // this loads the form and its control
      public Main() {
           InitializeComponent();
      }

      // the event that is triggered everytime the user starts the timer, this calls the mouse_event function with the parameters needed to locate mouse cursors and its button current state
      private void StartClicking(Object obj, EventArgs args) {
            mouse_event(MOUSEEVENTF_LEFTDOWN | MOUSEEVENTF_LEFTUP, (uint)X, (uint)Y, 0, 0);
      }

      // this class returns an integer that will be declared as the timer interval value, the radio button in the form gives the user an option to select 5, 15, 20 to 60 seconds interval
      private int ClickInterval() {
            if (fifteenSecondsRadioButton.Checked == true) {
                  return 15000;
            } else if (twentySecondsRadioButton.Checked == true) {
                  return 20000;
            } else if (oneMinuteRadioButton.Checked == true) {
                  return 60000;
            } else {
                  // the default value of 5000 milliseconds / 5 seconds is returned every time a condition isn't met
                  return 5000;
            }
      }

      // buttons
      private void startClickingButton_Click(object sender, EventArgs e) {
            int interval = ClickInterval();
            stopButton.Enabled = true;

            // disable the group box that's holds the interval option so that the user cannot change it at runtime
            timerGroupBox.Enabled = false;

            // calls the event, assign the interval value and start the timer
            timer.Tick += new EventHandler(StartClicking);
            timer.Interval = interval;
            timer.Start();

            // the label value is changed to "clicking" to let the user knows the application current status
            status.Text = String.Format("Clicking with {0} seconds interval", interval / 1000);
            startClickingButton.Enabled = false;
      }

      private void stopButton_Click(object sender, EventArgs e) {
            // as soon as the stop button is clicked, enable start button and the timer interval group box
            startClickingButton.Enabled = true;
            timerGroupBox.Enabled = true;
            timer.Stop();

            // change the current status to "not clicking"
            status.Text = String.Format("Not clicking");
            stopButton.Enabled = false;
      }
}
}

Download Auto Clicker Installer

Additional Information

Be sure to add controls with the same name as what is declared in the code, otherwise you’ll need to change the code to avoid errors.You can try adding a masked text box that will allow the user to input his/her desired time interval, but be careful not to let the user set a value lower than 1 seconds or a time interval that is not enough to stop the application from clicking.

The program needed .Net framework, install the framework if you want to use the software.Hope the code works, happy coding…

Leave a Reply