How can i get the mouse to automatically click???? Like on its own
Printable View
How can i get the mouse to automatically click???? Like on its own
Use the Mouse_Event API, eg.
------------------Code:Private Type POINTAPI
x As Long
y As Long
End Type
Private Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long
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 MOUSEEVENTF_LEFTDOWN = &H2
Private Const MOUSEEVENTF_LEFTUP = &H4
Private Sub Command1_Click()
Dim tPoint As POINTAPI
Call GetCursorPos(tPoint)
Call mouse_event(MOUSEEVENTF_LEFTDOWN, tPoint.x, tPoint.y, 0, 0)
Call mouse_event(MOUSEEVENTF_LEFTUP, tPoint.x, tPoint.y, 0, 0)
End Sub
Aaron Young
Analyst Programmer
[email protected]
[email protected]
Two comments.
1. You don't need to specify the dx and dy if the dwFlags doesn't include MOUSEEVENTF_ABSOLUTE. If you don't include it, the mouse_event procedure will move the cursor dx pixels to the right and dy pixels down. (0, 0) means don't move it at all.
2. You can click in one call, by combining MOUSEEVENTF_LEFTDOWN with MOUSEEVENTF_LEFTUP (&H2 Or &H4 = &H6).
------------------Code: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 MOUSEEVENTF_LEFTDOWN = &H2
Private Const MOUSEEVENTF_LEFTUP = &H4
Private Sub Command1_Click()
Call mouse_event(MOUSEEVENTF_LEFTDOWN Or MOUSEEVENTF_LEFTUP, 0, 0, 0, 0)
End Sub
Yonatan
Teenage Programmer
E-Mail: [email protected]
ICQ: 19552879
[This message has been edited by Yonatan (edited 11-06-1999).]