Reputation: 43
we want our .bat file to send the "Enter" key every second. Is it possible? If so, how are we supposed to do that?
Will %SendKeys% {ENTER}
work?
Our code currently:
@echo off
cls
color 0a
:loop
%SendKeys% {ENTER}
timeout /t 1 /nobreak >nul
goto :loop
Upvotes: 0
Views: 38508
Reputation: 4085
It is not possible to send keys in batch files without using a third party utility or VBScript. Here is a hybrid VBScript-batch file that sends the Enter key every 1 second(s) continuously.
@if (@CodeSection == @Batch) @then
@echo off
set SendKeys=CScript //nologo //E:JScript "%~F0"
cls
color 0a
:loop
%SendKeys% "{ENTER}"
timeout /t 1 /nobreak >nul
goto :loop
@end
var WshShell = WScript.CreateObject("WScript.Shell");
WshShell.SendKeys(WScript.Arguments(0));
NOTE: To change the keys inputted simply change the {enter}
value.
Upvotes: 3
Reputation: 202
first download nircmd from here: http://nircmd.nirsoft.net/
create a batch file in the same directory where nircmd is and type:
@echo off
:loop
nircmd sendkeypress enter
timeout /t 1 /nobreak >nul
goto :loop
Upvotes: 1