I need a way to detect when the user presses the arrow keys in a windows batch file. I think the easiest way would be to use a command line tool that echoes the decimal value of whatever key has been pressed, and go from there. It would be easier to set the key value directly to a batch variable, but I can manage to do so without (via a FOR loop to set a command output to a variable)
The only other thing I got is using a keylogger, and checking the log file for the arrow keys, but this does not work well, and I don't like (and neither would a client) keyloggers.
here is an example of how I might use it:
for /f "tokens=1,2 delims=[]" %%A in ('foo.exe') do set input=%%B
:: the above justs sets the output of the command "foo.exe" the variable %input%
if %input%==37 echo you pressed the left arrow key.
if %input%==38 echo you pressed the up arrow key.
if %input%==39 echo you pressed the right arrow key.
if %input%==40 echo you pressed the left arrow key.
so I just need a program where when I type some command from the command prompt, foo.exe
, the program waits for the user to press a button, and whatever button is pressed, is recorded and outputed in it's decimal form (Virtual key code, and you can look up a list here.) like this 37
(The key for the left mouse button)