如何使一个批处理文件来运行一个热键 [英] How to make a batch file to run a hotkey
问题描述
每当我开始我的Windows我想执行一个热键(按Ctrl + Alt + 1)使用批处理文件,并把它在启动文件夹中。是,即使可能吗?是否有一个命令是什么?
Every time I start my Windows I want to execute a hotkey (Ctrl+Alt+1) using a batch file and putting it in startup folder. Is that even possible? Is there a command for that?
推荐答案
您不能直接从一个批处理文件发送键,相反,你可以创建一个VB脚本发送键和一个.bat文件调用此脚本
You can't send keys directly from a batch file, instead you can create a VB script to send the keys and call this script from a .bat file
将下面的code到VB脚本,例如sendkeys.vbs(^是Ctrl和%是Alt键)
Put the following code to a VB script, for example sendkeys.vbs (^ is Ctrl and % is Alt)
Set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.SendKeys "^%1"
将下面的code到一个批处理文件,例如sendkeys.bat(VB脚本所需的完整路径,如果他们不是在同一个文件夹中)
Put the following code to a batch file, for example sendkeys.bat(required full path of the VB script if they are not in the same folder)
wscript "sendkey.vbs"
最后,把sendkeys.bat到Windows启动文件夹中。
Finally, put sendkeys.bat to Windows startup folder.
这篇关于如何使一个批处理文件来运行一个热键的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!