如何使一个批处理文件来运行一个热键 [英] How to make a batch file to run a hotkey

查看:1411
本文介绍了如何使一个批处理文件来运行一个热键的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

每当我开始我的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.

的SendKeys在VB脚本

这篇关于如何使一个批处理文件来运行一个热键的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆