Desperate to change command window buffer size or alternate

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
MKANET
Posts: 160
Joined: 31 Mar 2012 21:31

Desperate to change command window buffer size or alternate

#1 Post by MKANET » 06 Jun 2012 12:54

To my horror, I just realized that the text color changing utility (as well as other ones I've tried) have a strange bug in it which requires the command window's vertical buffer size to be large enough in order for colors to be displayed correctly. I didn't notice this bug since I always have my buffer size set to 300 lines or more. When I reset the history back to the default 25 lines, my heart practically stopped. Without the buffer size being large enough, the colors on the screen spill over; making a big mess. My entire batch file uses this color changing utility all over the place. :(

I am hoping someone much smarter than me can figure out the best way to handle this with the least amount of code change to my gigantic batch file.

Where, even the simplest code can trigger this bug in any of the below utilities. I can't find any mention of this bug anywhere.
Image

Test.cmd

Code: Select all

:start
chgcolor.exe 80
echo Test test test test test
chgcolor.exe 07
echo      -Test test test test test
echo      -test test test test test
goto start



chgcolor.exe
http://www.mailsend-online.com/blog/set ... -file.html
CoColor.exe
http:\\www.horstmuc.de/win/cocolor.zip
ColorX.exe
http:\\www.westmesatech.com/files/sst27.zip

MKANET
Posts: 160
Joined: 31 Mar 2012 21:31

Re: Desperate to change command window buffer size or altern

#2 Post by MKANET » 06 Jun 2012 13:03

I am able to circumvent this bug by using the below subroutine (without an external utility). However, the current syntax to use it is far too different than what I'm using now. So, maybe there's a way to use this technique; however, still keep very close to the same syntax I currently have in my gigantic batch file; so it would work as close to the below syntax as possible :

Current method in gigantic batch file:

Code: Select all

chgcolor.exe 80
echo Test test test test test
chgcolor.exe 07




Below code doesnt have the bug; probably because there's better control when it reaches end-of-line or carriage return. If there was a way to change this to work similar to the other utilities; without the same problem.

Code: Select all


:start             
call :txtcolor 4f "test test test test test test" /n
ECHO     -TEST test test test test test test
ECHO     -TEST test test test test test test
goto start



goto end
:txtcolor Color  Str  [/n]
for /F "tokens=1,2 delims=#" %%a in ('"prompt #$H#$E# & echo on & for %%b in (1) do

rem"') do set "DEL=%%a"
<nul >"%temp%\x" set /p "=%DEL%%DEL%%DEL%%DEL%%DEL%%DEL%.%DEL%"
setlocal
set "str=%~2"
call :txtcolorvar %1 str %3
if exist "%temp%\x" del /q "%temp%\x" >nul
exit /b
:txtcolorvar  Color  StrVar  [/n]
for /F "tokens=1,2 delims=#" %%a in ('"prompt #$H#$E# & echo on & for %%b in (1) do

rem"') do set "DEL=%%a"
<nul >"%temp%\x" set /p "=%DEL%%DEL%%DEL%%DEL%%DEL%%DEL%.%DEL%"
if not defined %~2 exit /b
setlocal enableDelayedExpansion
set "str=a%DEL%!%~2:\=a%DEL%\..\%DEL%%DEL%%DEL%!"
set "str=!str:/=a%DEL%/..\%DEL%%DEL%%DEL%!"
set "str=!str:"=\"!"
pushd "%temp%"
findstr /p /A:%1 "." "!str!\..\x" nul
if /i "%~3"=="/n" echo(   
if exist "%temp%\x" del /q "%temp%\x" >nul
exit /b

:end

MKANET
Posts: 160
Joined: 31 Mar 2012 21:31

Re: Desperate to change command window buffer size or altern

#3 Post by MKANET » 06 Jun 2012 14:45

Simple solution...

AutoIt, again, saved me. It has the ability to change the console buffer without changing the height. Problem resolved!

Fawers
Posts: 187
Joined: 08 Apr 2012 17:11
Contact:

Re: Desperate to change command window buffer size or altern

#4 Post by Fawers » 06 Jun 2012 16:40

Apparetly, AutoIt can do anything. :lol:

Post Reply