Output text without linefeed, even with leading space or =
Moderator: DosItHelp
Re: Output text without linefeed, even with leading space or =
I love the "%comspec%" /d /k <nul solution here. However, I have a situation using this technique that I haven't been able to solve. Let's say I have a very simple menu like this:
Now, suppose I want to use a terminal escape sequence to display a title rather than using just the title command (so that it appears the same when run as Administrator or not):
Where can I use this terminal escape sequence in this scenario?
Edit: To clarify somewhat further, if I put the terminal escape sequence for the title and run as Administrator, the title will appear as "Main Menu" until it hits the %comspec% line, when it changes to "Administrator: Main Menu." I'm trying to avoid that change.
Edit 2: I can sort of get it to work if I use this:
However, that introduces the issue of a carriage return to the next line. Any suggestions?
Code: Select all
@echo off
setlocal enabledelayedexpansion
for /f %%g in ('%__APPDIR__%forfiles.exe /p "%~dp0." /m "%~nx0" /c "cmd /c echo 0x07"') do set "bel=%%g"
for /F "delims=#" %%e in ('"prompt #$E# & for %%e in (1) do rem"') do set "ESC=%%e"
:top
cls
echo(
echo Main Menu
echo(
echo 1...............................................Refresh
echo 2...............................................Quit
echo(
set "prompt= SELECT FROM THE MENU ABOVE AND PRESS [Enter]:"
"%comspec%" /d /k <nul
set /p "INPUT="
IF '%INPUT%'=='1' GOTO refresh
IF '%INPUT%'=='2' GOTO quit
:refresh
goto top
:quit
exit /b
Code: Select all
echo %ESC%]0;Main Menu%BEL%
Edit: To clarify somewhat further, if I put the terminal escape sequence for the title and run as Administrator, the title will appear as "Main Menu" until it hits the %comspec% line, when it changes to "Administrator: Main Menu." I'm trying to avoid that change.
Edit 2: I can sort of get it to work if I use this:
Code: Select all
"%comspec%" /d /k <nul & echo %ESC%]0;Main Menu%BEL%
Re: Output text without linefeed, even with leading space or =
Hi atfon,
escape sequences can be outputted with the `set /p` technique.
escape sequences can be outputted with the `set /p` technique.
Code: Select all
"%comspec%" /d /k <nul & <nul set /p ".=%ESC%]0;Main Menu%BEL%"
Re: Output text without linefeed, even with leading space or =
Thanks Jeb! I tried a bit with set /p, but didn't think to use the ".= for this. Worked like a charm.jeb wrote: ↑19 Nov 2021 02:07Hi atfon,
escape sequences can be outputted with the `set /p` technique.
Code: Select all
"%comspec%" /d /k <nul & <nul set /p ".=%ESC%]0;Main Menu%BEL%"