I am currently writing a batch file that will output a plain text file in the format of a scripting language that an application on my phone uses to automate screen touches. What I would like to do is create a sub-menu that is called when only specific options in my main menu are chosen. So here is the current version on my batch file. The problem I am having is when I try to create a sub-menu my action for Yes is not executed, it just returns to the main menu.
Here is what I have so far.
:MENU
ECHO.
ECHO ###################################################
ECHO # Select an Option to begin building your script #
ECHO ###################################################
ECHO.
ECHO 1 - START
ECHO 2 - SEARCH
ECHO 3 - X_COORDINATES
ECHO 4 - Y_COORDINATES
ECHO 5 - 1
ECHO 6 - 2
ECHO 7 - 3
ECHO 8 - 4
ECHO 9 - 5
ECHO 10 - 6
ECHO 11 - 7
ECHO 12 - 8
ECHO 13 - 9
ECHO 14 - 0
ECHO 15 - QUIT
ECHO.
SET /P M=TYPE 1-15 THEN PRESS ENTER:
IF %M%==1 GOTO START
IF %M%==2 GOTO SEARCH
IF %M%==3 GOTO X_COORDINATES
IF %M%==4 GOTO Y_COORDINATES
IF %M%==5 GOTO 1
IF %M%==6 GOTO 2
IF %M%==7 GOTO 3
IF %M%==8 GOTO 4
IF %M%==9 GOTO 5
IF %M%==10 GOTO 6
IF %M%==11 GOTO 7
IF %M%==12 GOTO 8
IF %M%==13 GOTO 9
IF %M%==14 GOTO 0
IF %M%==15 GOTO QUIT
This code block below is what I am having trouble with. When "Y" is selected, it does not print the line of touchPress 0 1315 2451
or the sleep 590
line of script code into my file that I will later use in the application to automate searching a game map from end to end without having to manually type whatever the combinations are on a 1200x1200 grid. It simply returns to the menu like "N" was chosen.
(I chose to use @ECHO OFF
for the sub-menu because I didn't want to confuse myself or anyone else that may use this to write their own searching script by printing it in the console window before they ever even started using the batch file. I only wanted the sub-menu to be shown when certain options were chosen from the main menu.)
@ECHO OFF
:SUB-MENU
SET /P M=TYPE Y,N THEN PRESS ENTER:
IF %M%==Y @ECHO touchPress 0 1315 2451>>"C:\Documents and Settings\Master Terminal\Desktop\speedSearchFiles\speedSearch.txt"
@ECHO sleep 590>>"C:\Documents and Settings\Master Terminal\Desktop\speedSearchFiles\speedSearch.txt"
IF %m%==N GOTO MENU
This is just a break to place emphasis on the problem block in the batch file.
ECHO.
:START
cd..
cd..
cd C:\Documents and Settings\
cd C:\Documents and Settings\Master Terminal\
cd C:\Documents and Settings\Master Terminal\Desktop\
cd C:\Documents and Settings\Master Terminal\Desktop\speedSearchFiles
@echo :start>"C:\Documents and Settings\Master Terminal\Desktop\speedSearchFiles\speedSearch.txt"
GOTO :MENU
:SEARCH
@ECHO touchPress 0 493 2148>>"C:\Documents and Settings\Master Terminal\Desktop\speedSearchFiles\speedSearch.txt"
@ECHO sleep 590>>speedSearch.txt
GOTO :MENU
:X_COORDINATES
@ECHO touchPress 0 529 1221>>"C:\Documents and Settings\Master Terminal\Desktop\speedSearchFiles\speedSearch.txt"
@ECHO sleep 590>>speedSearch.txt
GOTO :MENU
:Y_COORDINATES
@ECHO touchPress 0 1131 1208>>"C:\Documents and Settings\Master Terminal\Desktop\speedSearchFiles\speedSearch.txt"
@echo sleep 590>>speedSearch.txt
GOTO :MENU
:1
@ECHO touchPress 0 220 1800>>"C:\Documents and Settings\Master Terminal\Desktop\speedSearchFiles\speedSearch.txt"
@ECHO sleep 590>>speedSearch.txt
GOTO :SUB-MENU
Any advice is much appreciated. I have an additional question to this project, but I would like to get this portion solved before digging further into problems.