Timeout with GUI adjustments breaks its design after first second passes

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Message
Author
Aacini
Expert
Posts: 1885
Joined: 06 Dec 2011 22:15
Location: México City, México
Contact:

Re: Timeout with GUI adjustments breaks its design after first second passes

#16 Post by Aacini » 18 Nov 2023 12:07

Why you didn't tested my solution as I wrote it (more than one month ago)?

The last code you tested have duplicated the line # 45 and inserted an additional line # 48: del spacesFile.txt that is the cause that your code (not the mine!) don't works...

Antonio

DOSadnie
Posts: 143
Joined: 21 Jul 2022 15:12
Location: Coding Kindergarten

Re: Timeout with GUI adjustments breaks its design after first second passes

#17 Post by DOSadnie » 09 Dec 2023 10:24

Aacini wrote:
18 Nov 2023 12:07
Why you didn't tested my solution as I wrote it (more than one month ago)?
As I have just now tested this once more: that code
Aacini wrote:
13 Oct 2023 18:33

Code: Select all

@echo off

cls
echo/
echo    Info about what the script will do
echo/

setlocal EnableDelayedExpansion

rem Get an ASCII CR (13) character
for /F %%a in ('copy /Z "%~F0" NUL') do set "CR=%%a"
rem Create a file with *just* 3 spaces
call :CreateSpacesFile 3

set "countdown=3"

echo    Executing in:
echo/

for /L %%i in (%countdown%,-1,1) do (
    type SpacesFile.txt
    <nul set /p "=%%i!CR!"
    ping 127.0.0.1 -n 2 > nul
)

:: Here be dragons

echo    The script has been executed
echo/
echo    [Press any key to close this CMD window]
echo/

pause > nul
goto :EOF



:CreateSpacesFile numOfSpaces
setlocal EnableDelayedExpansion
set "spcs="
for /L %%i in (1,1,%1) do set "spcs=!spcs! "
set /P ^"=X^
% Do not remove this line %
%spcs%^" > spacesFile.tmp < nul
findstr /V "X" spacesFile.tmp > spacesFile.txt
del spacesFile.tmp
exit /B
ends up showing to me
Info about what the script will do

Executing in:

3The 2The 1The The script has been executed

[Press any key to close this CMD window]
and leaves behind a leftover in form of the spacesFile.txt file, even after I close the CMD window


As for
Aacini wrote:
18 Nov 2023 12:07
The last code you tested have duplicated the line # 45 and inserted an additional line # 48: del spacesFile.txt that is the cause that your code (not the mine!) don't works...
it does not help when I remove those two lines, i.e. using

Code: Select all

@echo off

cls
echo/
echo    Info about what the script will do
echo/

setlocal EnableDelayedExpansion

rem Get an ASCII CR (13) character
for /F %%a in ('copy /Z "%~F0" NUL') do set "CR=%%a"
rem Create a file with *just* 3 spaces
call :CreateSpacesFile 3

set "countdown=3"

echo    Executing in:
echo/

for /L %%i in (%countdown%,-1,1) do (
    type SpacesFile.txt
    <nul set /p "=%%i!CR!"
    ping 127.0.0.1 -n 2 > nul
)

:: Here be dragons

echo    The script has been executed
echo/
echo    [Press any key to close this CMD window]
echo/

pause > nul
goto :EOF



:CreateSpacesFile numOfSpaces
setlocal EnableDelayedExpansion
set "spcs="
for /L %%i in (1,1,%1) do set "spcs=!spcs! "
set /P ^"=X^
% Do not remove this line %
%spcs%^" > spacesFile.tmp < nul
findstr /V "X" spacesFile.tmp > spacesFile.txt
del spacesFile.tmp
exit /B
also produces
Info about what the script will do

Executing in:

3The 2The 1The The script has been executed

[Press any key to close this CMD window]
and of course creates the issue of the spacesFile.txt being left over in the folder



I already had thought about using Power Shell for this

But [as already have noted it here viewtopic.php?f=3&t=10887&p=69007#p69096] currently in the Windows Console [conhost.exe] it is most likely impossible to see digits of a countdown at the bottom of window while also retaining ability to scroll it up an not have the view being thrown back down after passing of another second. The new Windows Terminal [windowsterminal.exe] however will not snap to the bottom on output if user scrolls up- it only snaps to the bottom on output if user is already at the bottom of window when it occurs

And so, as Windows Terminal by default replaces the old Windows Terminal since Windows 11 22H2, but installing it on older systems has many prerequisites [https://github.com/Microsoft/Terminal#prerequisites] - thus it is easier for me to just wait out this issue. [More info:
https://github.com/microsoft/terminal/issues/15962]

Thus I think there is no sense in continuing this wild goose chase - as in the end I must be able to freely scroll freely the screen up and down when the countdown takes place


Thank you for your help

Post Reply