WshShortcut.Hotkey

The HotKey property provides the hot key of a shortcut object. A hot key is a keyboard shortcut to start or switch to a program.

Syntax

WshShortcut.HotKey = strHotKey
 

Remarks

BNF syntax of strHotKey is as follows:

Hotkey   ::=   modifier* keyname
modifier ::=   "ALT+" | "CTRL+" | "SHIFT+" | "EXT+"
keyname  ::=   "A" .. "Z" | 
               "0".. "9" | 
               "Back" | "Tab" | "Clear" | "Return" |
               "Escape" | "Space" | "Prior" | ...

Complete key names are found in WINUSER.H. Hotkey is case-insensitive.

Hotkeys can only activate shortcuts located on the Windows desktop or the Windows Start menu .

Windows Explorer does not accept ESC, ENTER, TAB, SPACE, PRINT SCREEN, or BACKSPACE, even though WshShortcut.Hotkey supports these in compliance with the Win32 API. It is therefore recommended that you not use these keys in your shortcut.

Example

Set WshShell = Wscript.CreateObject("Wscript.WshShell")
strDesktop = WshShell.SpecialFolders("Desktop")
Set oMyShortcut = WshShell.CreateShortcut(strDesktop & "\a_key.lnk")
OMyShortcut.TargetPath = "%windir%\notepad.exe"
oMyShortCut.Hotkey = "ALT+CTRL+F"
oMyShortCut.Save
Wscript.Echo oMyShortCut.HotKey = "Alt+Ctrl+F"

See Also

WshSpecialFolders object


© 1997 by Microsoft Corporation. All rights reserved.