0

I am currently trying to work on a batch file that opens up a command prompt, once opened the command prompt starts simulating typing, here is what I have so far Coding:

@echo off 
setlocal 
for %%i in (H e l l o  H o w  A r e  y o u) do ( 
    set /p "=%%i"<nul 
    ping 169.254.0.0 -n 1 -w 500 >nul 
) 
echo; 
goto :EOF

the problem I have is, I can only do one word, when I start the command prompt it starts typing it, like this HelloHowAreYou I need the words to be separated, is there anything I can do? Oh, I'm also on Windows 7

  • how about just adding a space? `set /p "=%%i " – Stephan Mar 02 '15 at 17:49
  • I messed up on my coding, let me fix it real quick, I tried your suggestion, and while it adds the space, it just makes the word appear, it doesn't do the letters indivudually, and if I add spaces like (H e l l o h o w a r e y o u) It does the letters spaced also. – planelover390 Mar 02 '15 at 17:55
  • Example: https://gist.github.com/davidruhmann/6073962 – David Ruhmann Mar 02 '15 at 18:46
  • @DavidRuhmann SSL error, google can't verify the site is secure so it won't let me go to it – planelover390 Mar 02 '15 at 20:12
  • possible duplicate of [Batch File: Typewriter Effect](http://stackoverflow.com/questions/28369536/batch-file-typewriter-effect) – rojo Mar 03 '15 at 03:58

2 Answers2

0

Copy of my example from Gist: https://gist.github.com/davidruhmann/6073962 since OP is unable to access GitHub.com

@echo off
call :Typing "hello world!"
exit /b 0

:: Use a known invalid reserved IP address because it should always timeout.
:: http://en.wikipedia.org/wiki/Reserved_IP_addresses
:: 127.0.0.1 will never timeout and will always return each tick in 1 second.
:Typing <Message>
setlocal
set "Message=%~1"
:TypingLoop
ping 192.0.2.0 -n 1 -w 500 >nul
if "%Message:~1,1%"==" " ( <nul set /p "=%Message:~0,2%" ) else ( <nul set /p "=%Message:~0,1%" )
set "Message=%Message:~1%"
if defined Message goto TypingLoop
endlocal
exit /b 0
David Ruhmann
  • 11,064
  • 4
  • 37
  • 47
0

This works in Windows-XP:

@echo off 
setlocal 
for %%i in (H e l l o " " H o w " " A r e " " y o u) do ( 
    set /p "=%%~i"<nul 
    ping 169.254.0.0 -n 1 -w 500 >nul 
) 
echo; 
goto :EOF

However, in newer Windows versions the set /P command eliminate leading spaces, so I am not shure if this method works in Windows 7.

Aacini
  • 65,180
  • 12
  • 72
  • 108