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?
Right-click the desktop and select New > Shortcut. Choose a location, ideally the same as your batch file, and click Next. Then enter a name for the shortcut and click Finish. Now right-click your new shortcut file, select Properties, and update the Target field to point to your batch file.
Introduction. In Windows operating system, any program can run through a batch program. Also, it is very hard to press any key through a batch program. But it is possible indirectly by a batch program using VBScript.
The quickest way to access the Run command window is to use this keyboard shortcut: Windows + R. Simply hold down the Windows key and press R on your keyboard.
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.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With