How to make a batch file to run a hotkey

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

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"

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"

Finally, put sendkeys.bat to Windows startup folder.

SendKeys in VB Script


The original question was tagged autohotkey.

You can, indeed, use a batch file to run a autohotkey script.

In your batch file, just run autohotkey and send the path to your script as the parameter.

"c:\program files (x86)\autohotkey\autohotkey.exe" "c:\scripts\hotkey.ahk"

And in your autohotkey script, do something like this:

send ^!1
exit

That's it.

Of course, if autohotkey is installed on the computer, you could just put a link to the script in your startup folder in the start menu. That's what I do.