Blupig has reported a post.
Reason:
Forum: Verified Programs
Assigned Moderators: Gohan, Wolfdog, RsProd, -Ryan, RwmRS2
Posted by: Blupig
Original Content:
Reason:
Post: [VB] Open Source Clickermy links are dead, this can probably be moved to programming since the source code is still posted in text
Forum: Verified Programs
Assigned Moderators: Gohan, Wolfdog, RsProd, -Ryan, RwmRS2
Posted by: Blupig
Original Content:
In response to this thread: http://sythe.org/showthread.php?t=1309686
I thought I'd make an open source, shitty, autoclicker for people to learn from, but in a real language. It's fully commented and all the features work, I just didn't bother adding any error handling so be careful. Definitely room for improvement.
![]()
Download the program ONLY:
Clicker.zip - 22 KB
Download the VB.net SOURCE ONLY:
Clicker Source.zip - 85 KB
If you get any errors with WindowsHookLib references, the DLL is in the /bin/Debug/ folder.
Code:'' We're using the 3rd party WindowsHookLib library to easily '' create a keyboard hook for the hotkeys Imports WindowsHookLib Public Class Form1 '' This system function will return the system's current time Private Declare Function timeGetTime Lib "winmm.dll" () As Long '' Allows us to invoke mouse events (we're going to use left '' mouse button up and down) Public 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 '' Constant 32-bit integers (cannot be changed) which '' correspond to the left down and up events so we can '' raise them Public Const MOUSEEVENTF_LEFTDOWN As Int32 = &H2 Public Const MOUSEEVENTF_LEFTUP As Int32 = &H4 '' Declare keyboard hook, it's WithEvents so we can access '' the object's events WithEvents kHook As New KeyboardHook '' This is how we'll tell when we need to stop clicking if the '' user doesn't want to click infinitely Dim limCount As Integer = 0 '' Self explanatory shit Private Sub optTimes_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles optTimes.CheckedChanged txtTimes.Enabled = optTimes.Checked End Sub Private Sub cmdStart_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdStart.Click '' More self explanatory shit cmdStart.Enabled = False cmdStop.Enabled = True '' Change timer interval according to the "time between clicks" tmrClick.Interval = CInt(txtInterval.Text) '' Tell the computer to finish its current stack before moving '' on, this makes sure that the interval was changed properly '' (Might not be necessary on most machines, I was having '' memory issues while debugging so I popped it in for good measure) Application.DoEvents() '' Let's start fuckin clickiiiin tmrClick.Enabled = True End Sub Private Sub Form1_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing '' Remove keyboard hook (for memory purposes) kHook.RemoveHook() End Sub Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load '' Install the keyboard hook so we can assign instructions to '' different events that have to do with the keyboard kHook.InstallHook() End Sub '' When a key on the keyboard is pushed DOWN Private Sub kHook_KeyDown(ByVal sender As Object, ByVal e As WindowsHookLib.KeyboardEventArgs) Handles kHook.KeyDown '' If the key that was pressed was F2... If e.KeyCode = Keys.F2 Then '' If the start button is enabled, raise its click event If cmdStart.Enabled = True Then cmdStart.PerformClick() '' Same shit here except with F4 and with the stop button ElseIf e.KeyCode = Keys.F4 Then If cmdStop.Enabled = True Then cmdStop.PerformClick() End If End Sub Private Sub cmdStop_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdStop.Click '' Self explanatory shit tmrClick.Enabled = False cmdStart.Enabled = True cmdStop.Enabled = False End Sub '' Timer event Private Sub tmrClick_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tmrClick.Tick '' If the clicking is infinite... If optInf.Checked = True Then '' Left mouse button DOWN apimouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0) '' Left mouse button UP (DOWN+UP = CLICK! :D ) apimouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, 0) '' Wait randomly between 0 and the random offset (offset '' will add time onto the timer interval so that the interval '' is technically random within the range the user sets) '' Note that it does not directly change the timer's interval, '' just makes the timer wait a bit longer than usual depending '' on the random offset. Wait(RandomInt(0, CInt(txtRandClicks.Text))) '' If clicking isn't infinite... Else '' If our counter is equal to the times entered by the user minus '' one, then stop everything (minus one because I like my counters '' to start at 0, it's just a matter of programming style). You can '' make the counter start at 1 in the declaration at the top of the '' code and remove the minus one here if it confuses you. If limCount = CInt(txtTimes.Text) - 1 Then tmrClick.Enabled = False cmdStart.Enabled = True cmdStop.Enabled = False End If '' Mouse click n shit, then wait randomly apimouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0) apimouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, 0) Wait(RandomInt(0, CInt(txtRandClicks.Text))) '' Add 1 onto the count limCount = limCount + 1 End If End Sub '' Wait function Private Sub Wait(ByVal MS As Long) Try '' Assign the current system time to a variable Dim systime As Long = timeGetTime() '' Run a blank loop to "pause" the system (asynchronously! :D ) '' while the recorded system time + the milliseconds to wait are '' bigger than the current system time Do Loop While systime + MS > timeGetTime() Catch ex As Exception '' Do nothing, cause idgaf about errors End Try End Sub '' Generates a random integer between "min" and "max" Public Function RandomInt(ByVal min As Integer, ByVal max As Integer) As Integer '' Declare generator as static so it doesn't produce the same '' numbers over and over Static gen As Random = New Random() '' Return generated number Return gen.Next(min, max) End Function End Class

















