Assign VBS Script to a Keyboard Shortcut

非 Y 不嫁゛ 提交于 2019-12-01 23:40:20

问题


I have a very basic VBS script that I plan on using frequently on my Windows 7 machine. Is there any way I can bind it to a keyboard shortcut so I don't have to navigate to it through Explorer obnoxiously.

I realize this question does not directly pertain to programming, or even scripting for that matter, but I could not find a straight answer online or through my own experimentation. I'm sure that there is a simple solution somewhere...

Thank you for taking the time to read, and hopefully respond to my inquiry. Evin Ugur.


回答1:


Windows does have built-in support for shell shortcut keys, where a keypress is used to invoke an *.lnk file that launches your VBScript (using either cscript or wscript).

Create a shortcut file, have it invoke your VBScript file directly or run cscript or wscript with the appropriate arguments, then save it and open its Properties sheet and set a keystroke in the "Shortcut key" field (I suggest something like Ctrl+Alt+K).

Then, whenever you press Ctrl+Alt+K, regardless of the active application, your script will be invoked.

A more heavy-duty alternative is AutoHotKey: http://www.autohotkey.com/



来源:https://stackoverflow.com/questions/13371572/assign-vbs-script-to-a-keyboard-shortcut

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!