send keys method cmd

1.1k views Asked by At

I've been working on a batch file to perform several tasks and usually ask the user to enter 1, or 2 to choose between options.

This time, I'd like to use a different approach, keystrokes so that the user can select a choice by pressing the UP or DOWN arrow keys. This is where I want to include the UP/DOWN strokes for the user.

    echo 1. go to the main menu? 
    echo 2. Go to the next backup?
    echo.
    set INPUT=
    set /P INPUT=Type input: %=%

    If "%INPUT%"=="1" goto start1 
    If "%INPUT%"=="2" goto start2

The above portion of code works for me. Now instead of using "1" or "2" I'd like to use {DOWN} or {UP}

https://msdn.microsoft.com/en-us/library/8c6yea83(v=vs.84).aspx

I don't seem to make this work out in my batch by trying these lines:

    If /I "%INPUT%"=="{UP}" goto start1 
    If /I "%INPUT%"=="{DOWN}" goto start2

Here:

batch file that detects keystrokes. how?

This article adresses the topic of choosing between keystrokes awsd and I've tested it, it works perfect only in my case I need for the arrow keys to perform the task.

0

There are 0 answers