Windows 脚本宿主  

Hotkey 属性

为快捷方式指派组合键,或确定指派给快捷方式的组合键。

object.Hotkey = strHotkey

参数

object
WshShortcut 对象。
strHotkey
代表指派给快捷方式的组合键的字符串。

语法

strHotkey 的语法为:

[KeyModifier]KeyName
KeyModifier
可以是以下的任何一个组合键:ALT+、CTRL+、SHIFT+、EXT+

注意   EXT+ 表示“扩展键”。— 此处是为了防止日后将新的 SHIFT-键类型添加到字符集内。

KeyName
a ... z、 0 ... 9、F1 F12 ...

KeyName 不区分大小写。

说明

热键是一组组合键,当同时按下所有相关键时将启动快捷方式。

在 Windows 2000 中,有效的热键总是以 CTRL + ALT 开头。

示例

下面的示例演示 HotKey 属性的用法:

<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>

请参阅

运行脚本 | WshSpecialFolders 对象 | WshShortcut 对象