send
Grupo de Telegram
play_arrow
Este sitio utiliza cookies propias y de terceros. Si continúa navegando consideramos que acepta el uso de cookies. OK Más Información.

Autoclick

  • 0 Respuestas
  • 1292 Vistas

0 Usuarios y 1 Visitante están viendo este tema.

Conectado ANTRAX

  • *
  • Administrator
  • Mensajes: 5283
  • Actividad:
    35%
  • Reputación 28
  • ANTRAX
    • Ver Perfil
    • Underc0de
    • Email
  • Skype: underc0de.org
  • Twitter: @Underc0de
« en: Julio 26, 2010, 12:01:46 pm »
Agregas un modulo de clase y lo llamas clsmouse y copias:

Código: Visual Basic
  1. Option Explicit
  2. Public Event PositionChanged()
  3. Public Event SytemClick(ByVal Button As MouseButtonConstants)
  4. Private Const VK_RBUTTON As Long = &H2
  5. Private Const VK_MBUTTON As Long = &H4
  6. Private Const VK_LBUTTON As Long = &H1
  7. Private Const MOUSEEVENTF_LEFTDOWN As Long = &H2
  8. Private Const MOUSEEVENTF_LEFTUP As Long = &H4
  9. Private Const MOUSEEVENTF_MIDDLEDOWN As Long = &H20
  10. Private Const MOUSEEVENTF_MIDDLEUP As Long = &H40
  11. Private Const MOUSEEVENTF_RIGHTDOWN As Long = &H8
  12. Private Const MOUSEEVENTF_RIGHTUP As Long = &H10
  13. Private Type POINTAPI
  14. X As Long
  15. Y As Long
  16. End Type
  17. Private m_WatchPosition As Boolean
  18. Private m_WatchSystemClicks As Boolean
  19. Private m_Position As New clsmouseposition
  20. Private Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long
  21. Private Declare Sub mouse_event Lib "user32" (ByVal dwFlags As Long, _
  22. ByVal dx As Long, _
  23. ByVal dy As Long, _
  24. ByVal cButtons As Long, _
  25. ByVal dwExtraInfo As Long)
  26.  
  27. Public Sub Click(Optional MouseButton As MouseButtonConstants = vbLeftButton)
  28. If (MouseButton = vbLeftButton) Then
  29. Call mouse_event(MOUSEEVENTF_LEFTDOWN, 0&, 0&, 0&, 0&)
  30. Call mouse_event(MOUSEEVENTF_LEFTUP, 0&, 0&, 0&, 0&)
  31. ElseIf (MouseButton = vbMiddleButton) Then
  32. Call mouse_event(MOUSEEVENTF_MIDDLEDOWN, 0&, 0&, 0&, 0&)
  33. Call mouse_event(MOUSEEVENTF_MIDDLEUP, 0&, 0&, 0&, 0&)
  34. ElseIf (MouseButton = vbRightButton) Then
  35. Call mouse_event(MOUSEEVENTF_RIGHTDOWN, 0&, 0&, 0&, 0&)
  36. Call mouse_event(MOUSEEVENTF_RIGHTUP, 0&, 0&, 0&, 0&)
  37. End If
  38. End Sub
  39.  
  40. Private Function CompKey(KCode As Long) As Boolean
  41. Dim Result As Long
  42. Result = GetAsyncKeyState(KCode)
  43. If Result = -32767 Then
  44. CompKey = True
  45. Else
  46. CompKey = False
  47. End If
  48. End Function
  49.  
  50. Public Property Get Position() As clsmouseposition
  51. Set Position = m_Position
  52. End Property
  53.  
  54. Public Property Let TimerEvent(ByVal Dummmy As Boolean)
  55. Dim CurPos As POINTAPI
  56. Dim Value As MouseButtonConstants
  57. Static First As Boolean
  58. Static mx As Long
  59. Static my As Long
  60. If m_WatchPosition Then
  61. Call GetCursorPos(CurPos)
  62. If First Then
  63. If CurPos.X <> mx Or CurPos.Y <> my Then
  64. RaiseEvent PositionChanged
  65. End If
  66. End If
  67. mx = CurPos.X
  68. my = CurPos.Y
  69. End If
  70. If m_WatchSystemClicks Then
  71. If CompKey(VK_LBUTTON) Then
  72. Value = vbLeftButton
  73. End If
  74. If CompKey(VK_RBUTTON) Then
  75. Value = Value Or vbRightButton
  76. End If
  77. If CompKey(VK_MBUTTON) Then
  78. Value = Value Or vbMiddleButton
  79. End If
  80. If Value <> 0 Then
  81. RaiseEvent SytemClick(Value)
  82. End If
  83. End If
  84. First = True
  85. End Property

Agregas otro y lo llamas clsmouseposition y pegas:

Código: Visual Basic
  1. Option Explicit
  2. Private Type POINTAPI
  3. X As Long
  4. Y As Long
  5. End Type
  6. Private m_x As Long
  7. Private m_y As Long
  8. Private Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long
  9. Private Declare Function SetCursorPos Lib "user32" (ByVal X As Long, _
  10. ByVal Y As Long) As Long
  11.  
  12. Private Sub GetPosition()
  13. Dim P As POINTAPI
  14. Call GetCursorPos(P)
  15. m_y = P.Y
  16. m_x = P.X
  17. End Sub
  18.  
  19. Public Property Get X() As Long
  20. Call GetPosition
  21. X = m_x
  22. End Property
  23.  
  24. Public Property Let X(lngValue As Long)
  25. Call SetCursorPos(lngValue, m_y)
  26. m_x = lngValue
  27. End Property
  28.  
  29. Public Property Get Y() As Long
  30. Call GetPosition
  31. Y = m_y
  32. End Property
  33.  
  34. Public Property Let Y(lngValue As Long)
  35. Call SetCursorPos(m_x, lngValue)
  36. m_y = lngValue
  37. End Property

y en el form pones:

Código: Visual Basic
  1. Option Explicit
  2. Private WithEvents Mouse As clsmouse
  3.  
  4. Private Sub Command1_Click()
  5. With Mouse
  6. .Position.X = coodenada
  7. .Position.Y = coordenada
  8. .Click (vbLeftButton)
  9. End With
  10. 'Si quieres pones x=100 y y=100, pones el Startupposition en center screen y que tu form no ocupe la pantalla completa hazlo pequeño para que veas que pasa
  11. End Sub
  12.  
  13. Private Sub Form_Load()
  14. Set Mouse = New clsmouse
  15. End Sub
« Última modificación: Mayo 12, 2014, 03:10:03 pm por Expermicid »


 

¿Te gustó el post? COMPARTILO!