
Open toolbar button Menu with {%ALT}!!!!!
After working a bit, and reading a message from Olivier Belzile
I found how to do it.
For those who could be interested in this issue I am posting the solution:
Private Declare Function SetCursorPos Lib "user32" (ByVal x As Long,
ByVal y As Long) 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)
Const MOUSEEVENTF_LEFTDOWN = &H2
Const MOUSEEVENTF_LEFTUP = &H4
Const MOUSEEVENTF_RIGHTDOWN = &H8
Const MOUSEEVENTF_RIGHTUP = &H10
Private Sub Command2_Click()
Dim r As Long
r = SetCursorPos((Form1.Left / Screen.TwipsPerPixelX) +
(Toolbar.Buttons(1).Width / Screen.TwipsPerPixelX), _
(Form1.Top / Screen.TwipsPerPixelY) +
(Toolbar.ButtonHeight / Screen.TwipsPerPixelY))
mouse_event MOUSEEVENTF_LEFTDOWN, _
(Form1.Left / Screen.TwipsPerPixelX) +
(Toolbar.Buttons(1).Width / Screen.TwipsPerPixelX), _
(Form1.Top / Screen.TwipsPerPixelY) +
(Toolbar.ButtonHeight / Screen.TwipsPerPixelY), _
0, _
0
mouse_event MOUSEEVENTF_LEFTUP, _
(Form1.Left / Screen.TwipsPerPixelX) +
(Toolbar.Buttons(1).Width / Screen.TwipsPerPixelX), _
(Form1.Top / Screen.TwipsPerPixelY) +
(Toolbar.ButtonHeight / Screen.TwipsPerPixelY), _
0, _
0
End Sub
You must define a Form and a Toolbar on it, also a Command button
(command2). Also, you need to add a dropdown button to the toolbar.
If there is any easier way to do this, please let me know.
Chris
Quote:
> Hi, My name is Christopher, I would like any advice related to next
> question:
> -How can I automatically, open a Toolbar Drop-Down Button Menu upon
> pressing an F-key.?
> Like what you do with the drop-down combo box, sending the key secuence
> {%ALT}
> reagards and thanks in advance...
> Chris.