Search code examples
batch-filecmdcommand

Batch Programming = How do i make characters appear slow when i echo then, like if you were typing them


If you have ever seen a hacker movie, you saw code appear slowly character by character as if someone was typing them. I want to do this in batch. I found some code that did a similar thing, but with hole lines instead.

The code can be found at: How to have multiple colors in a Windows batch file? dbenham's answer.

Ive tried using disableDelayedExpansion since the command "sounded" like it was going to do what i wanted, but i didnt get anywere

Thx for any help in advance.

Also, kinda example of what i want to do- text appearing slowly gif


Solution

  • Depending upon your string content, something as simple as this may suit you.

    @Echo Off
    
    Set "STRING=Try this, unfortunately it is untested!"
    
    For /F %%A In ('"Prompt $H&For %%B In (1) Do Rem"') Do Set "BS=%%A"
    
    For /F Delims^=^ EOL^= %%A In ('"(CMD/U/CEcho=%STRING%)|Find /V """'
    ) Do Set/P "=a%BS%%%A"<Nul & PathPing 127.0.0.1 -n -q 1 -p 100 1>Nul
    

    You can change the speed of letter display by adjusting the number 100 as necessary. Perhaps try it a 200 for slower typing, and at 50 for faster!