Auto-Clicker Help pl0x?

Posts 1–9 of 9 · Page 1 of 1
Auto-Clicker Help pl0x?
Okaay. so i was making an AutoClicker, and i encountered some problems.

i got it to work, with hotkeys too!

F1 - starts the clicking,
F2 - Is supposed to end it, but it doesnt ?

heres the code



Code:
Public Class Form1
    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)

    Private Sub Form1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles Me.KeyDown
        If e.KeyCode = Keys.F1 Then
            Timer1.Start()
        Else
            If e.KeyCode = Keys.F2 Then
                Timer1.Stop()
            End If
        End If
    End Sub
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        KeyPreview = True
    End Sub
    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

    Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
        MyMethod()
    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Timer1.Start()
    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        Timer1.Stop()
    End Sub
End Class
Uhh, what are the problems?
I want the key "F2"
to Stop the clicking but it does not.
Did i code it wrong?

Code:
Private Sub Form1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles Me.KeyDown
        If e.KeyCode = Keys.F1 Then
            Timer1.Start()
        Else
            If e.KeyCode = Keys.F2 Then
                Timer1.Stop()
            End If
        End If
    End Sub
Quote Originally Posted by SweetLEMONADE View Post
Okaay. so i was making an AutoClicker, and i encountered some problems.

i got it to work, with hotkeys too!

F1 - starts the clicking,
F2 - Is supposed to end it, but it doesnt ?

heres the code



Code:
Public Class Form1
    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)

    Private Sub Form1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles Me.KeyDown
        If e.KeyCode = Keys.F1 Then
            Timer1.Start()
        Else
            If e.KeyCode = Keys.F2 Then
                Timer1.Stop()
            End If
        End If
    End Sub
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        KeyPreview = True
    End Sub
    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

    Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
        MyMethod()
    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Timer1.Start()
    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        Timer1.Stop()
    End Sub
End Class
Oh my, the keys you calling hotkeys are not hotkeys. They only work if the Form1 has focus. Use real hotkey method. You can find out how to create one here:

http://www.mpgh.net/forum/33-visual-...odule-new.html

Fix this problem and I guess other problems will be solved automatically too (if you have any) !!
EDIT: EDIT:

Heres my current module,
Code:
Module Module1
    Public Declare Function GetAsyncKeyState Lib "user32" (ByVal vKey As Integer) As Int16
    Dim Timer1 As New Timer
    Dim Timer2 As New Timer

    Public Sub Timer1_Start() Handles Timer1.Tick
        If (GetAsyncKeyState(Keys.F2)) Then
            Timer2.Stop()
        End If
    End Sub
End Module
i get the error
Handles clause requires a WithEvents variable defined in the containing type or one of its base types.
---------------------------------------------------------------------------
Heres the From1 code stuff,
Code:
Public Class Form1
    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)
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        KeyPreview = True
    End Sub
    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

    Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
        MyMethod()
    End Sub
End Class
Quote Originally Posted by SweetLEMONADE View Post
EDIT: EDIT:

Heres my current module,
Code:
Module Module1
    Public Declare Function GetAsyncKeyState Lib "user32" (ByVal vKey As Integer) As Int16
    Dim Timer1 As New Timer
    Dim Timer2 As New Timer

    Public Sub Timer1_Start() Handles Timer1.Tick
        If (GetAsyncKeyState(Keys.F2)) Then
            Timer2.Stop()
        End If
    End Sub
End Module
You didn't add events to the timer. You've got to remember that if you're creating an object at runtime to define whether it has events or not. In your case it should be:

[php]
Public Declare Function GetAsyncKeyState Lib "user32" (ByVal vKey As Int32) As Int16
Public WithEvents Timer1 As New Timer
Public WithEvents Timer2 As New Timer
[/php]

And after that you should be able to handle their "tick" events.

Also, what is this line supposed to do:
[php]
Windows.Forms.Cursor.Position = New System.Drawing.Point(Windows.Forms.Cursor.Position )
[/php]

It's just like putting 1=1, there's no point to it.

EDIT: Did you post this on VBForums.com with the ID "Jaro"...
Add a timer to Form1 called tmrHotkeys. Make it enabled with a 250 interval.

At the top of the Form1 code, underneath Public Class Form1, add this:

Code:
Public Declare Function GetAsyncKeyState Lib "user32" (ByVal vKey As Integer) As Int16
In the tmrHotkeys.Tick event, add this code:

Code:
        If (GetAsyncKeyState(Keys.F2)) Then
            Timer2.Stop()
        End If
        If (GetAsyncKeyState(Keys.F3)) Then
            Timer2.Start()
        End If
Pressing F2 will stop the timer, F3 will start it. /done
Quote Originally Posted by Lolland View Post
Add a timer to Form1 called tmrHotkeys. Make it enabled with a 250 interval.

At the top of the Form1 code, underneath Public Class Form1, add this:

Code:
Public Declare Function GetAsyncKeyState Lib "user32" (ByVal vKey As Integer) As Int16
In the tmrHotkeys.Tick event, add this code:

Code:
        If (GetAsyncKeyState(Keys.F2)) Then
            Timer2.Stop()
        End If
        If (GetAsyncKeyState(Keys.F3)) Then
            Timer2.Start()
        End If
Pressing F2 will stop the timer, F3 will start it. /done
timer2 not declared
EDIT: i even renamed Timer2
to tmrHotkeys.
still, did not work
Change the "timer2" name in the code above to whatever the timer you wanna enable.
Posts 1–9 of 9 · Page 1 of 1
This thread is closed for replies.

Similar Threads

Tags for this Thread

None

Need help?