我想要实现的是我的批处理文件打开记事本并自动开始输入。到目前为止,这是我的代码:
@echo off
Start notepad
但我从哪里开始?我试过了:
@echo off
Start notepad
type "stuff"
exit
和类似的事情但它没有用。
有没有办法在批处理中执行此操作?
答案 0 :(得分:5)
这是一个小玩具,我掀起来以准人类风格输入lineN变量中的文本到控制台屏幕。
请参阅代码以获取有关如何加快速度或降低速度的提示。
@echo off
:: Ghost typer
setlocal enableextensions enabledelayedexpansion
set lines=6
set "line1=Twinkle twinkle little star"
set "line2=How I wonder what you are"
set "line3=Up above the world so high"
set "line4=Like a diamond in the sky"
set "line5=Twinkle twinkle little star"
set "line6=How I wonder what you are"
for /f %%a in ('"prompt $H&for %%b in (1) do rem"') do set "BS=%%a"
for /L %%a in (1,1,%lines%) do set num=0&set "line=!line%%a!"&call :type
pause>nul
goto :EOF
:type
set "letter=!line:~%num%,1!"
set "delay=%random%%random%%random%%random%%random%%random%%random%"
set "delay=%delay:~-6%"
if not "%letter%"=="" set /p "=a%bs%%letter%" <nul
:: adjust the 3 in the line below: higher is faster typing speed
for /L %%b in (1,3,%delay%) do rem
if "%letter%"=="" echo.&goto :EOF
set /a num+=1
goto :type
答案 1 :(得分:1)
这将是 - 嗯我不知道是否可以批量生产。 但,如果您在VBScript中进行编码,则可以在一个文件中执行此操作。
set ghost = wscript.CreateObject("WScript.Shell")
ghost.run "notepad"
wscript.sleep 3000
ghost.sendkeys "Hello."
wscript.sleep 1000
ghost.sendkeys "I am a magical ghost "
wscript.sleep 1000
ghost.sendkeys "who possesed your keyboard."
您将其保存为.vbs
而不是.bat
!
Explanation:
set ghost = wsc .... bla bla bla
- 创建一个新的WSCRIPTShell对象(这是打开记事本和“占用”键盘所必需的“
ghost.run "notepad"
- 打开记事本。
wscript.sleep 3000
- “睡眠”3000毫秒(即3秒)
ghost.sendkeys "Hello."
- 类型“你好。” (当然没有引号。)
应该很容易适应您的需求。 编辑:“睡觉”又称暂停总是在几毫秒内。通过将秒乘以1000得到毫秒。 1秒= 1000毫秒因为 1 * 1000 = 1000
答案 2 :(得分:1)
@echo off
echo Hello what is you name?
set /p %name%=
echo>Hello%name%.txt I have just taken over you computer.
:: the set command works in this format
:: The above echo will not show up in a command prompt if echo is off
:: You must use "echo >" for the batch file to create a text file
:: The word that you put immediately after the ">" will be the name of the file
:: you can also use a "%-%" command for the file name.
:: The batch file will create a new text file for each "echo >" command used
:: So if you want a lot of text in one document write all of the text on one line
:: P.S. I found this by accident while creating an inventory program XD
答案 3 :(得分:0)
查找“pv”命令并选中“-L”选项
” 数据传输修饰符
-L RATE, - rate-limit RATE 将传输限制为每秒最大RATE字节数。可以添加后缀“k”,“m”,“g”或“t”以表示千字节(* 1024),兆字节等。 “
... SO
回声“闪烁的小星星”&GT;我多么想知道你是什么“| pv -qL 10