Can I turn Caps on/of from a batch file in Win 7?
The only way I know from cmd.exe is by spawning powershell or vbs.
Drop this at the end of your batch, it toggles CAPSLOCK
start /b /wait powershell.exe -nologo -WindowStyle Hidden -sta -command "$wsh = New-Object -ComObject WScript.Shell;$wsh.SendKeys('{CAPSLOCK}')"
That calls out to powershell via command line and invokes the sendkeys, the alternative method is to echo similar commands into a %temp% file and then wscript %temp%\my.vbs
.
EDIT: Here is the IF statement to ensure it only turns capslock OFF
start /b /wait powershell.exe -nologo -WindowStyle Hidden -sta -command "IF ([console]::CapsLock -eq 'True'){$wsh = New-Object -ComObject WScript.Shell;$wsh.SendKeys('{CAPSLOCK}')}"
Using JP Software's TCC/LE, which can run batch scripts of course, it's as simple as the built-in KEYBD
command. So your wrapper script that you run with TCC/LE would be:
@echo off
:: Force CAPS LOCK on beforehand.
keybd /c1
call very-old-program
:: Force CAPS LOCK off afterwards.
keybd /c0