Ok , yo al poner ese código me sale un error que dice : Error 1 La instrucción no es válida en un espacio de nombres.
Y me subraya Private Sub esperar(ByVal espera As Long)
El codigo quedaria así :
Y me subraya Private Sub esperar(ByVal espera As Long)
El codigo quedaria así :
Código (vbnet) [Seleccionar]
Public Class Form1
Private Declare Sub mouse_event Lib "user32" (ByVal dwflags As Long, ByVal dx As Long, ByVal dy As Long, ByVal cbuttons As Long, ByVal dwExtraInfo As Long)
Private Const mouseclickup = 4
Private Const mouseclickdown = 2
Private Declare Function GetAsyncKeyState Lib "user32" (ByVal vkey As Long) As Integer
Declare Function GetTickCount Lib "kernel32" Alias "GetTickCount" () As Long
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
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
Windows.Forms.Cursor.Position = New Point(TextBox1.Text, TextBox2.Text)
mouse_event(mouseclickdown, 3, 7, 1, 2)
mouse_event(mouseclickup, 2, 5, 9, 3)
End Sub
Private Sub Timer2_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer2.Tick
Dim hotkey As Boolean
hotkey = GetAsyncKeyState(Keys.F3)
If hotkey = True Then Timer1.Start()
Dim hotkey1 As Boolean
hotkey1 = GetAsyncKeyState(Keys.F4)
If hotkey1 = True Then Timer1.Stop()
End Sub
Private Sub Timer3_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer3.Tick, Timer4.Tick
Label1.Text = Cursor.Position.X
Label2.Text = Cursor.Position.Y
End Sub
Private Sub RadioButton1_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton1.CheckedChanged
Timer1.Interval = (1)
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 NumericUpDown2_ValueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles NumericUpDown2.ValueChanged
Timer1.Interval = NumericUpDown2.Value
End Sub
End Class
Private Sub esperar(ByVal espera As Long)
Dim inicio As Long
Dim fin As Long
inicio = GetTickCount()
fin = inicio + espera 'espera es el tiempo del contador en milisec
While fin > GetTickCount
DoEvents()
End While
End Sub