Mouse Control

 How can I control the mouse ? For example, moving the mouse to anywhere with the coordinate (x,y) or the mouse automatically click on (x,y) ... Can you help me ?
ZeusGodAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
setiawanConnect With a Mentor Commented:
Public Declare Function SetCursorPos Lib "user32" (ByVal x As Long, ByVal y As Long) As Long

Public 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

Public Const MOUSEEVENTF_LEFTDOWN = &H2
Public Const MOUSEEVENTF_LEFTUP = &H4
Hi ZeusGod,

Public Const MOUSEEVENTF_MOVE = &H1
Public Type POINTAPI
    x As Long
    y As Long
    End Type

Public Sub SetMousePos(xPos As Long, yPos As Long)

    SetCursorPos xPos, yPos
End Sub

Public Sub LeftClick()
    mouse_event MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0
    mouse_event MOUSEEVENTF_LEFTUP, 0, 0, 0, 0
End Sub


You can use code above, by call :

  SetCursorPos x, y
  LeftClick

  regards

   danny
0
 
ZeusGodAuthor Commented:
Thanks.
0
All Courses

From novice to tech pro — start learning today.