SENDKEY for windows startup menu??

Maliki Hassani
Maliki Hassani used Ask the Experts™
on
Hi Experts,
Can someone please provide me the VBA SENDKEY code so I can open up my "WINDOWS START MENU"?  

I have looked every where and nothing seems to work.

THANK YOU!!
WINDOWS-SENKEY-FOR-VBA.doc
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Top Expert 2008

Commented:
try this: I don't think you can use sendkeys for that.

Thomas




Private Declare Sub keybd_event Lib "user32.dll" (ByVal bVk As Byte, ByVal bScan As Byte, ByVal dwFlags As Long, _
ByVal dwExtraInfo As Long)

Const VK_STARTKEY = &H5B
Const KEYEVENTF_KEYUP = &H2

Private Sub getstart()
    'WinKey down
    keybd_event VK_STARTKEY, 0, 0, 0
    'WinKey up
    keybd_event VK_STARTKEY, 0, KEYEVENTF_KEYUP, 0
End Sub

Open in new window

Author

Commented:
nutsch,
I am not sure how to run this.  Since it is private I dont see how I can call the macro to open up the start button?  Any suggestions?
Top Expert 2008
Commented:
You could remove the private. That was just an example. But you need to have the Private Declare at the top of that module.



Private Declare Sub keybd_event Lib "user32.dll" (ByVal bVk As Byte, ByVal bScan As Byte, ByVal dwFlags As Long, _
ByVal dwExtraInfo As Long)

Const VK_STARTKEY = &H5B
Const KEYEVENTF_KEYUP = &H2

Sub getstart()
    'WinKey down
    keybd_event VK_STARTKEY, 0, 0, 0
    'WinKey up
    keybd_event VK_STARTKEY, 0, KEYEVENTF_KEYUP, 0
End Sub

Open in new window

I believe "Ctrl+Esc" does it, but I'm not sure you can send these.  Autoit has it covered though:
http://www.autoitscript.com/autoit3/docs/appendix/SendKeys.htm

Also try:
set WshShell = CreateObject("WScript.Shell")
WshShell.SendKeys "^{ESC}"

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial