下面是我写了一个关于vbs脚本。本意是想先打开cmd,然后用SendKeys输入edit和{ENTER},这样就进入了edit界面,再用SendKeys相edit输入别的数据。
具体如下:
dim wshshell
set wshshell=WScript.CreateObject("WScript.Shell")
wshshell.Run "C:\WINDOWS\system32\cmd.exe"
WScript.Sleep 200
wshshell.SendKeys "edit"
WScript.Sleep 200
wshshell.SendKeys "{ENTER}"
WScript.Sleep 1000
wshshell.AppActivate "C:\WINDOWS\system32\cmd.exe - edit"
WScript.Sleep 2000
Rem 以上都是正常的,能有效地执行,可是下一步就不可以了:
wshshell.SendKeys "i"
尽管cmd edit 窗口已经是在激活状态,但最后这一步输入的 i 怎么也不出现edit的界面里,而我动手用键盘是能输入字符的,请教大侠,原因何在?
谢谢!!