简体   繁体   English

Windows 7命令提示符批量屏幕模拟键入

[英]Windows 7 command prompt batch onscreen simulated typing

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? 我遇到的问题是,我只能做一个单词,当我启动命令提示符时它开始输入它,就像这个HelloHowAreYou我需要分开的单词,有什么我可以做的吗? Oh, I'm also on Windows 7 哦,我也在Windows 7上

Copy of my example from Gist: https://gist.github.com/davidruhmann/6073962 since OP is unable to access GitHub.com 我的例子来自Gist: https ://gist.github.com/davidruhmann/6073962,因为OP无法访问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

This works in Windows-XP: 这适用于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. 但是,在较新的Windows版本中, set /P命令会消除前导空格,因此如果此方法适用于Windows 7,我并不感到害羞。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM