Page 1 of 1

Just for fun - cmd animation

Posted: 25 Feb 2010 14:10
by kpropell
Hi!
Been enjoying the dostips'tips and for fun, I want to make myself a small animation snipple displayed in cmd.exe...
But! I can't find (probably bad use of googleing?) a way to delay execution of next command to under a second. One second delay between the .txt
files is just terrible. Soooo, is there a way?

And the "code" could have a better solution I would think, but I don't know where to begin. Right now I'm doing it like this:

cls
type 1.txt
1 second delay
cls
type 2.txt
1 second delay
cls

But could it be possible to just tell cmd.exe to print all the 'txt files one at a time with x delay in-between and enjoy the show?

-Tudelu Kjell :)

edit:
I forgot, does a "graphics" library exists for cmd? Would be fun having multiple colours!

Re: Just for fun - cmd animation

Posted: 25 Feb 2010 17:22
by !k
Yes, you are bad use of googleing.

Code: Select all

@echo off
setlocal enableextensions enabledelayedexpansion
for %%f in (*.txt) do (
cls &color !random:~0,1!!random:~-1!
type "%%f"
ping localhost -n 2 >nul
)
cls &color
echo That's All Folks!

Re: Just for fun - cmd animation

Posted: 25 Feb 2010 18:07
by kpropell
I've read that one! I figured out how to delay between the txt-files, but is 0.5 seconds possible?
Thanks for the 'for and colour thing' tho ;) Just have to name the txt files better so that it fits in.!
If 1 second is minimum all usefulness will be that clock I soon got done.. Humhum :D

Search continues!

Re: Just for fun - cmd animation

Posted: 26 Feb 2010 07:02
by aGerman
You need a 3rd party app. You could write your own VBScript using batch.

Code: Select all

@echo off &setlocal

:: write the script
set "sleep=%temp%\sleep.vbs"
>%sleep% echo WScript.Sleep WScript.Arguments(0)

echo START
:: call the script with milli seconds as the parameter
%sleep% 200
echo END

pause

Note that calling the script takes some time. Thats why write less than 500 if you need 0.5 seconds

Regards
aGerman