Autoclick sugerencias y ayudas
Publicado: 31 Ago 2016, 00:26
Hola, me topé con este foro y vi algunos temas interesantes y pensé que aquí podría ser ayudado y aprender un poco más sobre VB. Estoy creando un autoclick y no veo que sea muy eficaz, les voy a dejar los códigos para que ustedes me digan en qué fallo, si hay algún error, podría mejorar esto o lo otro:
Public Class Form1
<System.Runtime.InteropServices.DllImport("user32")>
Private Shared Function GetAsyncKeyState(ByVal vkey As System.Windows.Forms.Keys) As Short
End Function
Public Declare Function SetWindowPos Lib "user32" (ByVal hwnd As Integer,
ByVal hWndInsertAfter As Integer, ByVal X As Integer, ByVal Y As Integer)
Shadows DoubleClick = 2
Shadows MouseDoubleClick = 4
Dim valueinterval = 4
Declare Sub mouse_event Lib "user32" Alias "mouse_event" (ByVal dwFlags As Integer, ByVal dx As Integer, ByVal dy As Integer, ByVal cButtons As Integer, ByVal dwExtraInfo As Integer)
Event Click1 As Action(Of AccessibleEvents)
Event Click2 As Action(Of AccessibleEvents)
Event Click3 As Action(Of AccessibleEvents)
Public Sub EnableDoubleBuffering()
' Set the value of the double-buffering style bits to true.
Me.SetStyle(ControlStyles.DoubleBuffer _
Or ControlStyles.UserPaint _
Or ControlStyles.AllPaintingInWmPaint, _
True)
Me.UpdateStyles()
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(Windows.Forms.Cursor.Position.X, Windows.Forms.Cursor.Position.Y)
Timer1.Interval = NumericUpDown1.Value
Label1.Text = Windows.Forms.Cursor.Position.X
Label2.Text = Windows.Forms.Cursor.Position.Y
Windows.Forms.Cursor.Position = New Point(TextBox1.Text, TextBox2.Text)
mouse_event(DoubleClick, 0UI, 0UI, 0UI, 0UI)
mouse_event(MouseDoubleClick, 0UI, 0UI, 0UI, 0UI)
mouse_event(valueinterval, 0UI, 0UI, 0UI, 0UI)
Windows.Forms.Cursor.Position = New Point(Label1.Text, Label2.Text)
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.F1)
If hotkey = True Then Timer1.Start()
Dim hotkey1 As Boolean
hotkey1 = GetAsyncKeyState(Keys.F2)
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
Dim Posicion As Boolean
Posicion = GetAsyncKeyState(Keys.F3)
If Posicion = True Then
TextBox1.Text = MousePosition.X : TextBox2.Text = MousePosition.Y
End If
If Posicion = False Then
End If
End Sub
End Class
Es que no da muchos clicks y sé que para que los dé es repetir una y otra vez la función mouse_event pero me gustaría que me explicaran más la forma del mouse_event se supone que es la forma en la que da los clicks al añadirle números y simbología, gracias.
Public Class Form1
<System.Runtime.InteropServices.DllImport("user32")>
Private Shared Function GetAsyncKeyState(ByVal vkey As System.Windows.Forms.Keys) As Short
End Function
Public Declare Function SetWindowPos Lib "user32" (ByVal hwnd As Integer,
ByVal hWndInsertAfter As Integer, ByVal X As Integer, ByVal Y As Integer)
Shadows DoubleClick = 2
Shadows MouseDoubleClick = 4
Dim valueinterval = 4
Declare Sub mouse_event Lib "user32" Alias "mouse_event" (ByVal dwFlags As Integer, ByVal dx As Integer, ByVal dy As Integer, ByVal cButtons As Integer, ByVal dwExtraInfo As Integer)
Event Click1 As Action(Of AccessibleEvents)
Event Click2 As Action(Of AccessibleEvents)
Event Click3 As Action(Of AccessibleEvents)
Public Sub EnableDoubleBuffering()
' Set the value of the double-buffering style bits to true.
Me.SetStyle(ControlStyles.DoubleBuffer _
Or ControlStyles.UserPaint _
Or ControlStyles.AllPaintingInWmPaint, _
True)
Me.UpdateStyles()
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(Windows.Forms.Cursor.Position.X, Windows.Forms.Cursor.Position.Y)
Timer1.Interval = NumericUpDown1.Value
Label1.Text = Windows.Forms.Cursor.Position.X
Label2.Text = Windows.Forms.Cursor.Position.Y
Windows.Forms.Cursor.Position = New Point(TextBox1.Text, TextBox2.Text)
mouse_event(DoubleClick, 0UI, 0UI, 0UI, 0UI)
mouse_event(MouseDoubleClick, 0UI, 0UI, 0UI, 0UI)
mouse_event(valueinterval, 0UI, 0UI, 0UI, 0UI)
Windows.Forms.Cursor.Position = New Point(Label1.Text, Label2.Text)
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.F1)
If hotkey = True Then Timer1.Start()
Dim hotkey1 As Boolean
hotkey1 = GetAsyncKeyState(Keys.F2)
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
Dim Posicion As Boolean
Posicion = GetAsyncKeyState(Keys.F3)
If Posicion = True Then
TextBox1.Text = MousePosition.X : TextBox2.Text = MousePosition.Y
End If
If Posicion = False Then
End If
End Sub
End Class
Es que no da muchos clicks y sé que para que los dé es repetir una y otra vez la función mouse_event pero me gustaría que me explicaran más la forma del mouse_event se supone que es la forma en la que da los clicks al añadirle números y simbología, gracias.