Hi,
I wanna know please how to cause the mouse to simulate a left click?
I already know how to set the cursor to a specific position using the API, but I dont know how to send then a left click.
Thanks.
Printable View
Hi,
I wanna know please how to cause the mouse to simulate a left click?
I already know how to set the cursor to a specific position using the API, but I dont know how to send then a left click.
Thanks.
Here is the method I use.
'declarations
Public Declare Sub mouse_event Lib "user32.dll" (ByVal dwFlags As Long, ByVal dx As Long, ByVal dy _
As Long, ByVal cButtons As Long, ByVal dwExtraInfo As Long)
Const MOUSEEVENTF_ABSOLUTE = &H8000
Const MOUSEEVENTF_LEFTDOWN = &H2
Const MOUSEEVENTF_LEFTUP = &H4
Const MOUSEEVENTF_MIDDLEDOWN = &H20
Const MOUSEEVENTF_MIDDLEUP = &H40
Const MOUSEEVENTF_MOVE = &H1
Const MOUSEEVENTF_RIGHTDOWN = &H8
Const MOUSEEVENTF_RIGHTUP = &H10
Const MOUSEEVENTF_WHEEL = &H80
Const MOUSEEVENTF_XDOWN = &H100
Const MOUSEEVENTF_XUP = &H200
Const WHEEL_DELTA = 120
Const XBUTTON1 = &H1
Const XBUTTON2 = &H2
'to hold the left button down
mouse_event MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0
'and then release the button
mouse_event MOUSEEVENTF_LEFTUP, 0, 0, 0, 0
You can use the constants above to simulate other mouse activity.
I can't edit my last post so...
<code>
'declarations
Public Declare Sub mouse_event Lib "user32.dll" (ByVal dwFlags As Long, ByVal dx As Long, ByVal dy _
As Long, ByVal cButtons As Long, ByVal dwExtraInfo As Long)
Const MOUSEEVENTF_ABSOLUTE = &H8000
Const MOUSEEVENTF_LEFTDOWN = &H2
Const MOUSEEVENTF_LEFTUP = &H4
Const MOUSEEVENTF_MIDDLEDOWN = &H20
Const MOUSEEVENTF_MIDDLEUP = &H40
Const MOUSEEVENTF_MOVE = &H1
Const MOUSEEVENTF_RIGHTDOWN = &H8
Const MOUSEEVENTF_RIGHTUP = &H10
Const MOUSEEVENTF_WHEEL = &H80
Const MOUSEEVENTF_XDOWN = & H100
Const MOUSEEVENTF_XUP = &H200
Const WHEEL_DELTA = 120
Const XBUTTON1 = &H1
Const XBUTTON2 = &H2
'to hold the left button down
mouse_event MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0
'and then release the button
mouse_event MOUSEEVENTF_LEFTUP, 0, 0, 0, 0
</code>
You can use the constants above to simulate other mouse activity.
ok... fine forget it
Hehe :) Square brackets Chris - [like these]
Hi
thanks for trying to help, BUT it is still not working.
it cant use the &H2 value as the first parameter in the procedure.
any other ideas guys?
thanks.
Hi
forget what I said.
it is now working.
I just had to switch it from Public to Private.
Thanks.