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
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
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
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
Public Declare Function GetAsyncKeyState Lib "user32" (ByVal vKey As Integer) As Int16
If (GetAsyncKeyState(Keys.F2)) Then
Timer2.Stop()
End If
If (GetAsyncKeyState(Keys.F3)) Then
Timer2.Start()
End If