How to Make an Auto Clicker in Visual Basic 2008

Feb 4, 2011 12:42 AM

This article will show you how to make an auto clicker program in Visual Basic Express Edition 2008.  An auto clicker is a very useful program that makes your mouse click many times automatically, wherever it's pointed.  It's a very good AFK (away from keyboard) program.  Just point your mouse on your screen and turn it on!  It's very useful for computer games (FPS, MMORPG, and others).

Click here to download Visual Basic 2008 Express Edition

Open a New Project

Open Visual Basic 2008.  Do a New Project (File > New Project or Ctrl+N)

Now, select Windows Forms Application and name it whatever you want.

Okay, you've created a new project!

What's Needed

For this auto clicker, you will need:

  • 4 Buttons
  • 2 TextBoxes
  • 1 Timer
  • Optional GroupBox

Like this:

Save your project.

Name Buttons and Config Form1

  • Name Button1 to Start = F3
  • Name Button2 to Stop = F4
  • Name Button3 to Interval
  • Name Button4 to Test Clicker
  • Name TextBox2 to 1
  • If you have a GroupBox, name it to Auto-Click
  • Name Form1 to (Your name here)'s Auto-Clicker
  • In Form1 Properties, select "MaximizeBox" and make it False.
  • Select "Show Icon" and make it false, too.

Now, it should look like this:

Save your project.

Coding

Now, let's go to the code part.

In the top of the code (under Public Class Form1) write this:

Declare Sub mouse_event Lib "user32" Alias "mouse_event" (ByVal dwFlags As Long, ByVal dx As Long, ByVal dy As Long, ByVal cButtons As Long, ByVal dwExtraInfo As Long)

Note

  • user32 is for x32 computers - change to user64 to x64 computers.

Double click on Form1 and write this:

MsgBox("My first auto-clicker - WonderHowTo.com", MsgBoxStyle.Information + MsgBoxStyle.OkOnly, "WonderHowTo.com")

Write this under Form1_Load:

Private Sub MyMethod()

        Windows.Forms.Cursor.Position = New System.Drawing.Point(Windows.Forms.Cursor.Position)

        mouse_event(&H2, 0, 0, 0, 1) 'cursor will go down (like a click)

        mouse_event(&H4, 0, 0, 0, 1) ' cursor goes up again

    End Sub

Now, double click on Timer1 and write this:

MyMethod()

Now, go back to the design tab and double click on Start = F3 and write this:

Timer1.Start()

Double click on Stop = F4 and write this:

Timer1.Stop()

Double click on Interval and write this:

          If TextBox1.Text = ("") Then

            MsgBox("Please, put a valid number value", MsgBoxStyle.Critical + MsgBoxStyle.OkOnly, "ERROR")

        Else

            Timer1.Interval = ((TextBox1.Text) * (1))

        End If

Double Click on Test Clicker and write this:

TextBox2.Text = TextBox2.Text + 1

Save your project.

Hotkey Part

Okay guys!  This is the last part before debug the project.

Do this:

Double click on Form1.  In top (but under the tabs), you will see a bolt.

Click in the bolt and select KeyDown. Then, write this:

        If e.KeyCode = Keys.F3 Then

            Timer1.Start()

        Else

            If e.KeyCode = Keys.F4 Then

                Timer1.Stop()

            End If

        End If

Now, go to Form1_Load and write this:

KeyPreview = True

Save your project.

Debug and Test It

You're done your Auto-Clicker!  Just press F5 (or click in the green arrow) for debug.

Put an interval (1 is the fastest speed; 1000 = 1 click per second), hover mouse in "Test Click" and press F3 to start.  Works?  Okay, now press F4 to stop.

Now, just share with your friends and be happy!

Comments

No Comments Exist

Be the first, drop a comment!