Post: [Tutorial] AutoClicking – Perfect for bots.
03-23-2011, 05:20 PM #1
(adsbygoogle = window.adsbygoogle || []).push({}); Welcome,

This is one of them questions that I see around the internet a lot and to be honest it’s a pretty neat piece of information to know if you code in Visual Basic (or you’re new to the whole coding scene).

AutoClicking can be used to make bots or to just create an application that stops the desired computer from clicking on anything else (I used this code to make a computer lock when I was at school so nobody could mess with my work).

There are TWO types of AutoClicking available to you: Click Anywhere or Click on desired co-ordinates. Either works but both have different uses.

So to start this tutorial we will start with the simple method, Click Anywhere!

Now to begin using these processes at the top of your form (in the code view) add these lines of code under the “Public Class Form1” line.

    Private Const MOUSEEVENTF_LEFTDOWN = &H2
Private Const MOUSEEVENTF_LEFTUP = &H4
Private Declare Sub mouse_event Lib "user32" (ByVal dwflags As Long, ByVal dx As Long, ByVal dy As Long, ByVal cbuttons As Long, ByVal dwextrainfo As Long)
What does this code do: It lets your application access the mouse_event function on Windows operating systems, without this code your program will not work!

Now we need to add the auto clicking code, you can do this two ways with two buttons that enable a timer with a set time or add a textbox and let the user set how many clicks to use, for the purpose of this tutorial I will show you the method of using a textbox.

Add a textbox, two buttons and a timer to your form. For the moment leave them with their default names.

Under the “Form1_Load” sub add

    Button2.enabled = false
Now name Button1 “Start” and Button2 “Stop” and under the “Button1_Click” add

    If TextBox1.Text = "" Then
TextBox1.Text = "1"
End If
Timer1.Interval = TextBox1.Text * 1000
Button1.Enabled = False
Button2.Enabled = True
Timer1.Enabled = True
What does this code do: The textbox1.text * 1000 means that the end-user will not have to enter milliseconds and only seconds or 0.1 seconds. The other code is self-explanatory.

Now under the “Button2_Click” add

    Timer1.Enabled = False
Button1.Enabled = True
Button2.Enabled = False
Now for the most important piece of code in this entire script, the clicking code. Under “Timer1_Tick” add this code.

      mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0)
mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, 0)
What does this code do: It simulates the user clicking and un-clicking the left mouse button. Clever aye’

Now that is the first part of this tutorial complete. You should now have a working auto-clicker! Congratulations.

But I want my application to click on certain co-ordinates, well add this one line of code with the timer section (above the mouse_event code).

    Cursor.Position = New Point(244, 471)


Thanks for reading. I hope this helps you with your Visual Basic quest. If you need a download of my code, please just ask and I will send you the project.
(adsbygoogle = window.adsbygoogle || []).push({});

The following 3 users say thank you to TheOsel for this useful post:

ⒿⒺⒷⓇⓄ, Matt1511,
04-08-2011, 11:52 AM #11
Prince Perciful
In / Out Shake It All About...
Originally posted by Nytol View Post
It's the code to build one. If you can't code then no I will not make you one, learn.


Dont be a knob.. Course i can.. and im normal... Normal coders ARE LAZY!!!!!! Its true...
04-08-2011, 03:30 PM #12
Originally posted by 08keelr View Post
Dont be a knob.. Course i can.. and im normal... Normal coders ARE LAZY!!!!!! Its true...


You can code but yet you don't understand what this code does, cool story bro'
04-08-2011, 03:43 PM #13
pretty useful i guess Smile
04-08-2011, 04:00 PM #14
ⒿⒺⒷⓇⓄ
At least I can fight
MW2 patches tought me something about coding.

Copyright © 2026, NextGenUpdate.
All Rights Reserved.

Gray NextGenUpdate Logo