如何制作批处理文件以运行热键 [英] How to make a batch file to run a hotkey

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

问题描述

每次启动 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

将下面的代码放到VB脚本中,例如sendkeys.vbs (^ is Ctrl and % is 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"

将下面的代码放到一个批处理文件中,例如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.

VB 脚本中的发送键

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

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