下面是我写了一个关于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的界面里,而我动手用键盘是能输入字符的,请教大侠,原因何在?
谢谢!!
Below is the VBS script I wrote. The intention was to first open cmd, then use SendKeys to type edit and {ENTER}, so as to enter the edit interface, and then use SendKeys to input other data into edit.
Specifically as follows:
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 The above all work normally and execute effectively, but the next step is not possible:
wshshell.SendKeys "i"
Although the cmd edit window is already in the activated state, the final step of typing "i" never appears in the edit interface, while I can type characters with the keyboard by hand. Please ask the expert, what is the reason?
Thank you!