Simulating clicks then differentiate between real clicks and simulated clicks
I am making a rapid fire script, which simulates a click every (x) milliseconds, but only when mousedown (Held). And it should stop when mouseup occurs, but because its simulating clicks it cannot differentiate between real clicks and simulated ones, meaning that it doesn't detect the real mouseup. Here is my current code:
Code:
Public Class Form1
Private Declare Function GetKeyPress Lib "user32" Alias "GetAsyncKeyState" (ByVal key As Integer) As Integer
Private Declare Sub mouse_event Lib "user32" (ByVal dwflags As Integer, ByVal dx As Integer, ByVal dy As Integer, ByVal cbuttons As Integer, ByVal dwextrainfo As Integer)
Private Const mouseclickup = 4
Private Const mouseclickdown = 2
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Timer1.Enabled = True
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Timer1.Enabled = False
End Sub
Private Sub NumericUpDown1_ValueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles NumericUpDown1.ValueChanged
Timer1.Interval = NumericUpDown1.Value
End Sub
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
mouse_event(mouseclickup, 0, 0, 0, 0)
mouse_event(mouseclickdown, 0, 0, 0, 0)
End Sub
Private Sub Timer2_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer2.Tick
If GetKeyPress(1) = 0 Then
'Mouseup
Timer1.Enabled = False
Else
'Mousedown
Timer1.Enabled = True
End If
End Sub
End Class


