How to Create a Mouse Auto Clicker in Visual Basic
Submitted by GeePee on Tuesday, March 24, 2015 - 22:56.
Introduction:
Welcome to my tutorial on how to create an Auto Mouse Clicker in Visual Basic.
Steps of Creation:
Step 1:
First lets create a form with; numericupdown1 to contain the amount of times to click, label1 to show the user the numericupdown1 will contain the amount of times to simulate clicks and a button to start the process.
Step 2:
Now lets make some variables to allow us to simulate clicks.
Step 3:
Next we want to create a simple function which will handle the clicking.
Step 4:
Finally, we want to click the amount of times chosen in numericupdown1 when button1 is clicked.
Project Complete!
Below is the full source code and download to the project files.
- Public Const MOUSEEVENTF_LEFTDOWN = &H2
- Public Const MOUSEEVENTF_LEFTUP = &H4
- Private Const MOUSEEVENTF_RIGHTDOWN = &H8
- Private Const MOUSEEVENTF_RIGHTUP = &H10
- Declare Function apimouse_event Lib "user32.dll" Alias "mouse_event" (ByVal dwFlags As Int32, ByVal dX As Int32, ByVal dY As Int32, ByVal cButtons As Int32, ByVal dwExtraInfo As Int32) As Boolean
- Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
- If (NumericUpDown1.Value > 0) Then
- MsgBox("Please position your mouse over the clicking position, then press enter to close this messagebox and continue.")
- For i As Integer = 0 To NumericUpDown1.Value - 1
- Call apimouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0)
- Call apimouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, 0)
- Next
- End If
- End Sub
- Public Class Form1
- Public Const MOUSEEVENTF_LEFTDOWN = &H2
- Public Const MOUSEEVENTF_LEFTUP = &H4
- Private Const MOUSEEVENTF_RIGHTDOWN = &H8
- Private Const MOUSEEVENTF_RIGHTUP = &H10
- Declare Function apimouse_event Lib "user32.dll" Alias "mouse_event" (ByVal dwFlags As Int32, ByVal dX As Int32, ByVal dY As Int32, ByVal cButtons As Int32, ByVal dwExtraInfo As Int32) As Boolean
- Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
- If (NumericUpDown1.Value > 0) Then
- MsgBox("Please position your mouse over the clicking position, then press enter to close this messagebox and continue.")
- For i As Integer = 0 To NumericUpDown1.Value - 1
- Call apimouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0)
- Call apimouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, 0)
- Next
- End If
- End Sub
- End Class
Add new comment
- 4159 views