Click to See Complete Forum and Search --> : Send Clicks
ant
July 11th, 2001, 06:11 PM
I know how to send keys, but is there a way to send double click?
Thanks in advance
--Ant
--------------------------------------------------
check out my newest freeware
E-mail me at: christopherfolger@hotmail.com
for the address
shree
July 11th, 2001, 07:07 PM
Use the mouse_event() API or the SendInput() API function.
ant
July 11th, 2001, 08:13 PM
what's the code for that?
--Ant
--------------------------------------------------
check out my newest freeware
E-mail me at: christopherfolger@hotmail.com
for the address
shree
July 11th, 2001, 11:31 PM
Here's the code for you.
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 Const MOUSEEVENTF_RIGHTDOWN = &H8
private Const MOUSEEVENTF_RIGHTUP = &H10
private Const MOUSEEVENTF_ABSOLUTE = &H8000
private Declare Function SetCursorPos Lib "user32" (byval x as Long, byval y as Long) as Long
private Sub Command1_Click()
'Simulate a double click as a quick series of two clicks
SetCursorPos 100, 100
mouse_event MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0
mouse_event MOUSEEVENTF_LEFTUP, 0, 0, 0, 0
mouse_event MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0
mouse_event MOUSEEVENTF_LEFTUP, 0, 0, 0, 0
End Sub
private Sub Command2_Click()
'Open the start menu in my display set at 1024*768
SetCursorPos 20, 760
mouse_event MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0
mouse_event MOUSEEVENTF_LEFTUP, 0, 0, 0, 0
End Sub
private Sub Form_DblClick()
MsgBox "I've been double clicked"
End Sub
private Sub Form_Load()
me.Left = 0
me.Top = 0
End Sub
Note that LEFTBUTTON to mouse_event means the physical left button, you should detect if the user has swapped buttons and make appropriate adjustments.
dknc
October 19th, 2009, 05:34 PM
What are the declaration of these for?
private Const MOUSEEVENTF_LEFTDOWN = &H2
private Const MOUSEEVENTF_LEFTUP = &H4
does it mean that in user32.dll, the events definition is &H2.. H4... ? I mean, is it like somewhere they have #define MOUSEEVENTF_LEFTDOWN &H2 or something like that?
and where I can find how these events are defined in the library?
so in another way, I can just type mouse_event &H2, 0, 0,0,0 ?
thanks
WoF
October 21st, 2009, 05:39 AM
Yes you can. It is like you assumed.
There is a define MOUSEEVENTF_LEFTDOWN 0x02 where 0x02 is the syntax for hexadecimal &H2. In C these definitions exist in .h files which are included in compilation when programming in C.
We VB guys have to make a similar definition if we want better readable code.
mouseevent 2,0,0,0,0 is telling nothing while
mouseevent MOUSEEVENTF_LEFTDOWN, 0,0,0,0 explains everything.
Still after years it is selfexplanatory, while you might forget what the &H2 was.
The equivalent or replacement of the define statement in C is
Private (or Public) Constant MOUSEEVENTF_LEFTDOWN = 2
I'd like to point you to this site here: http://allapi.mentalis.org/apilist/apilist.php
From there you can download a little utility called API-Viewer, which informs you about the values of any (or most) constants.
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.