Property:  WshShortcut.HotKey

object.HotKey

The HotKey property sets or retrieves the hotkey combination for a shortcut. Although you can set this property for any valid shortcut, it only creates a usable Windows HotKey mapping if the shortcut is on the Desktop or in the Start Menu. Once a valid hotkey mapping has been created, pressing the specified keys simultaneously will open the shortcut.

The value assigned to this property must be a string consisting of the concatenation of zero or more modifier key names, followed by a single standard key name. If the string is not in this format, a runtime error will result.

The valid modifier key-names (which are case insensitive) are:
"ALT+", "CTRL+", "SHIFT+", and "EXT+".

The valid standard keynames (also case insensitive) are:
"A" .. "Z", "0" .. "9", "Back", "Tab", "Clear", "Return", "Escape", "Space", and "Prior".

The following JScript code sets CTRL+ALT+Q as the hotkey combination for a shortcut called "Shortcut to Test.vbs.lnk" on the Windows 2000 Desktop of a user called "DevGuru".

Code:
objShell = WScript.CreateObject("WScript.Shell")
objShtCut = objShell.CreateShortcut
    ("C:\\Documents And Settings\\DevGuru\\Desktop\\Shortcut To Test.vbs.lnk")
objShtCut.HotKey = "CTRL+ALT+Q"
objShtCut.Save()
WScript.Echo(objShtCut.HotKey)

Output:
Alt+Ctrl+Q

Copyright 1999-2001 by Infinite Software Solutions, Inc. All rights reserved.
Trademark Information