i'm trying to simulate a typing effect in BATCH, and this is what i originally had:
@echo off
setlocal enabledelayedexpansion
set "word=example"
set "output="
for /l %%x in (0, 1, 6) do (
set "output=!output!!word:~%%x,1!"
cls
echo !output!_
ping localhost -n 1 -w 200 >nul
)
cls
echo !output!
pause
however, this doesn't work and instead just echoes the word entirely without simulating any typing effect. any solution?
tried: the code above
expected: a simple, clear typing effect in which it types out the word.
result: just echoed the word, and no typing effect was actually simulated.
Does this help at all?
It uses the built-in PATHPING.EXE
utility, (instead of PING.EXE
), to allow for a shorter delay between typed characters, in 'native batch'.
@Echo Off & SetLocal EnableExtensions DisableDelayedExpansion
Set "STRING=This may contain possibly problematic characters, ^?&|*=%%<>)!""
(For /F %%G In ('"Prompt $H& For %%H In (1) Do Rem"') Do For /F Delims^=^ EOL^= %%I In ('%SystemRoot%\System32\cmd.exe /V /U /E /D /C "Set /P "^=!STRING!" 0<NUL" ^| %SystemRoot%\System32\find.exe /V ""') Do Set /P "=.%%G%%I" 0<NUL & %SystemRoot%\System32\PATHPING.EXE 127.0.0.1 -n -q 1 -p 100 1>NUL) & Echo(
Pause
Just run it, as is, to see it working, then feel free to change the content of STRING
as needed. You can also adjust the 100
in the PATHPING
arguments to see how that affects the 'typing' effect.