Compartir a través de


Hotkey Property

Assigns a key-combination to a shortcut, or identifies the key-combination assigned to a shortcut.

                      object.Hotkey = strHotkey

Arguments

  • object
    WshShortcut object.

  • strHotkey
    A string representing the key-combination to assign to the shortcut.

The syntax of strHotkey is:

[KeyModifier]KeyName
  • KeyModifier
    Can be any one of the following: ALT+, CTRL+, SHIFT+, EXT+.

    Note

    EXT+ means "Extended key." — it appears here in case a new type of SHIFT-key is added to the character set in the future.

  • KeyName
    a ... z, 0 ... 9, F1 F12, ...

    The KeyName is not case-sensitive.

Remarks

A hotkey is a combination of keys that starts a shortcut when all associated keys are held down at the same time.

  • Hotkeys can be used to start shortcuts located on your system's desktop and in the Windows Start menu.

    Note

    Another name for a hotkey is a Keyboard Shortcut.

In Windows 2000, valid Hotkeys always begin with CTRL + ALT.

Applies To:

WshShortcut Object

Example

The following example demonstrates the use of the HotKey property.

<package>
   <job id="vbs">
      <script language="VBScript">
         set WshShell = WScript.CreateObject("WScript.Shell")
         strDesktop = WshShell.SpecialFolders("Desktop")
         set oShellLink = WshShell.CreateShortcut(strDesktop & "\Shortcut Script.lnk")
         oShellLink.TargetPath = WScript.ScriptFullName
         oShellLink.WindowStyle = 1
         oShellLink.Hotkey = "Ctrl+Alt+e"
         oShellLink.IconLocation = "notepad.exe, 0"
         oShellLink.Description = "Shortcut Script"
         oShellLink.WorkingDirectory = strDesktop
         oShellLink.Save
      </script>
   </job>

   <job id="js">
      <script language="JScript">
         var WshShell = WScript.CreateObject("WScript.Shell");
         strDesktop = WshShell.SpecialFolders("Desktop");
         var oShellLink = WshShell.CreateShortcut(strDesktop + "\\Shortcut Script.lnk");
         oShellLink.TargetPath = WScript.ScriptFullName;
         oShellLink.WindowStyle = 1;
         oShellLink.Hotkey = "Ctrl+Alt+e";
         oShellLink.IconLocation = "notepad.exe, 0";
         oShellLink.Description = "Shortcut Script";
         oShellLink.WorkingDirectory = strDesktop;
         oShellLink.Save();
      </script>
   </job>
</package>

See Also

Concepts

Running Your Scripts

Running Your Scripts

Reference

WshSpecialFolders Object