|
-
Sep 11th, 2000, 08:50 AM
#1
Thread Starter
Registered User
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.
-
Sep 11th, 2000, 09:09 AM
#2
Hyperactive Member
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.
-
Sep 11th, 2000, 09:13 AM
#3
Hyperactive Member
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.
-
Sep 11th, 2000, 09:13 AM
#4
Hyperactive Member
-
Sep 11th, 2000, 09:21 AM
#5
Frenzied Member
Hehe Square brackets Chris - [like these]
Harry.
"From one thing, know ten thousand things."
-
Sep 11th, 2000, 09:23 AM
#6
Thread Starter
Registered User
not working.
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.
-
Sep 11th, 2000, 09:40 AM
#7
Thread Starter
Registered User
oops...working!
Hi
forget what I said.
it is now working.
I just had to switch it from Public to Private.
Thanks.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|