Is it possible to create a sub-menu in a windows batch file? -


i writing batch file output plain text file in format of scripting language application on phone uses automate screen touches. create sub-menu called when specific options in main menu chosen. here current version on batch file. problem having when try create sub-menu action yes not executed, returns main menu.

here have far.

:menu echo. echo ################################################### echo # select option begin building 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 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 having trouble with. when "y" selected, not print line of touchpress 0 1315 2451 or sleep 590 line of script code file later use in application automate searching game map end end without having manually type whatever combinations on 1200x1200 grid. returns menu "n" chosen.

(i chose use @echo off sub-menu because didn't want confuse myself or else may use write own searching script printing in console window before ever started using batch file. wanted sub-menu shown when options chosen main menu.)

@echo off :sub-menu set /p m=type y,n press enter: if %m%==y @echo touchpress 0 1315 2451>>"c:\documents , settings\master terminal\desktop\speedsearchfiles\speedsearch.txt" @echo sleep 590>>"c:\documents , settings\master terminal\desktop\speedsearchfiles\speedsearch.txt" if %m%==n goto menu 

this break place emphasis on problem block in batch file.

echo. :start cd.. cd.. cd c:\documents , settings\ cd c:\documents , settings\master terminal\ cd c:\documents , settings\master terminal\desktop\ cd c:\documents , settings\master terminal\desktop\speedsearchfiles @echo :start>"c:\documents , settings\master terminal\desktop\speedsearchfiles\speedsearch.txt" goto :menu :search @echo touchpress 0 493 2148>>"c:\documents , settings\master terminal\desktop\speedsearchfiles\speedsearch.txt" @echo sleep 590>>speedsearch.txt goto :menu :x_coordinates @echo touchpress 0 529 1221>>"c:\documents , settings\master terminal\desktop\speedsearchfiles\speedsearch.txt" @echo sleep 590>>speedsearch.txt goto :menu :y_coordinates @echo touchpress 0 1131 1208>>"c:\documents , settings\master terminal\desktop\speedsearchfiles\speedsearch.txt" @echo sleep 590>>speedsearch.txt goto :menu :1 @echo touchpress 0 220 1800>>"c:\documents , settings\master terminal\desktop\speedsearchfiles\speedsearch.txt" @echo sleep 590>>speedsearch.txt goto :sub-menu 

any advice appreciated. have additional question project, portion solved before digging further problems.

first, can use instead of

cd.. cd.. cd c:\documents , settings\ cd c:\documents , settings\master terminal\ cd c:\documents , settings\master terminal\desktop\ cd c:\documents , settings\master terminal\desktop\speedsearchfiles 

simple single line

cd /d "c:\documents , settings\master terminal\desktop\speedsearchfiles" 

or perhaps better

cd /d "%userprofile%\desktop\speedsearchfiles" 

if user account name master terminal.

second, if describe batch user should enter on prompt, batch user can press key return without entering anything. better predefine variable default value case.

and batch user can enter string , not recommend. prepare batch file user input well.

@echo off :sub-menu set "m=n" set /p "m=type y,n press enter: " rem prevent syntax error if user enters 1 or more double quotes removing them. set "m=%m:"=%" if /i "%m%"=="y" echo touchpress 0 1315 2451>>"c:\documents , settings\master terminal\desktop\speedsearchfiles\speedsearch.txt" echo sleep 590>>"c:\documents , settings\master terminal\desktop\speedsearchfiles\speedsearch.txt" goto menu 

y or y interpreted yes, else interpreted no.

for understanding used commands , how work, open command prompt window, execute there following commands, , read entirely pages displayed each command carefully.

  • cd /?
  • echo /?
  • goto /?
  • if /?
  • rem /?
  • set /?

Comments

Popular posts from this blog

resizing Telegram inline keyboard -

command line - How can a Python program background itself? -

php - "cURL error 28: Resolving timed out" on Wordpress on Azure App Service on Linux -