分配热键以通过其桌面快捷方式执行 .vbs 文件
Assign a hotkey to execute a .vbs file through its desktop shortcut
我已经通过以下方式为我的 vbs 文件创建了一个快捷方式
我想给这个快捷方式分配一个热键,这样我就可以在不打开文件的情况下执行代码。也许类似于 Ctrl + Shift + P。
当我在编辑器中输入 .shortcutkey 时,它变成了 .ShortcutKey 并且我确定可以通过宏为其分配快捷键。但是我不知道怎么办。
这是我的代码:
shortcutHere = "C:\Users\" & Environ("Username") & "\Desktop\" & purpose & ".lnk"
With CreateObject("WScript.Shell").CreateShortcut(shortcutHere)
.TargetPath = ThisWorkbook.Path & "\" & purpose & ".vbs"
.Description = "HotKey: Ctrl + Shift + P"
.ShortcutKey '??????
.Save
End With
有人可以帮帮我吗?
右边的属性是HotKey
,不是ShortcutKey
,所以你的代码应该是
shortcutHere = "C:\Users\" & Environ("Username") & "\Desktop\" & purpose & ".lnk"
With CreateObject("WScript.Shell").CreateShortcut(shortcutHere)
.TargetPath = ThisWorkbook.Path & "\" & purpose & ".vbs"
.Description = "HotKey: Ctrl + Shift + P"
.HotKey = "CTRL+SHIFT+P"
.Save
End With
我已经通过以下方式为我的 vbs 文件创建了一个快捷方式
我想给这个快捷方式分配一个热键,这样我就可以在不打开文件的情况下执行代码。也许类似于 Ctrl + Shift + P。 当我在编辑器中输入 .shortcutkey 时,它变成了 .ShortcutKey 并且我确定可以通过宏为其分配快捷键。但是我不知道怎么办。
这是我的代码:
shortcutHere = "C:\Users\" & Environ("Username") & "\Desktop\" & purpose & ".lnk"
With CreateObject("WScript.Shell").CreateShortcut(shortcutHere)
.TargetPath = ThisWorkbook.Path & "\" & purpose & ".vbs"
.Description = "HotKey: Ctrl + Shift + P"
.ShortcutKey '??????
.Save
End With
有人可以帮帮我吗?
右边的属性是HotKey
,不是ShortcutKey
,所以你的代码应该是
shortcutHere = "C:\Users\" & Environ("Username") & "\Desktop\" & purpose & ".lnk"
With CreateObject("WScript.Shell").CreateShortcut(shortcutHere)
.TargetPath = ThisWorkbook.Path & "\" & purpose & ".vbs"
.Description = "HotKey: Ctrl + Shift + P"
.HotKey = "CTRL+SHIFT+P"
.Save
End With