我正在尝试编写一个使用命令shell和.sendkeys函数来操作Telnet的HTA。我有一切正常工作,除了Telnet没有收到我的转义密钥!我已经尝试了尽可能多的格式化选项。我还使用“-e N”参数启动了Telnet以简化转义序列,但是我选择的字符只是回显到终端而不是被解释为转义键。
令我困惑的部分是它作为wsh脚本运行,但是当代码从HTA运行时却不行。
Sub TestCmd
On Error Resume Next
//Dim WshShell
set WshShell=CreateObject("WScript.Shell")
WshShell.run "cmd.exe"
//WshShell.AppActivate "cmd"
Sleep 1
WshShell.Sendkeys "telnet.exe 130.160.176.219 4998 -e z {enter}"
Sleep 1
WshShell.SendKeys "sendir,1:1,1,37764,1,1,340,168,21,22,21,22,21,22,21,22,21,22,21,22,21,22,21,22,21,64,21,64,21,64,21,64,21,64,21,64,21,64,21,64,21,22,21,64,21,22,21,64,21,22,21,22,21,22,21,22,21,64,21,22,21,64,21,22,21,64,21,64,21,64,21,64,21,4833"
WshShell.SendKeys ("{Enter}")
Sleep 1
WshShell.SendKeys "sendir,1:1,10,37764,1,1,340,168,21,22,21,22,21,22,21,22,21,22,21,22,21,22,21,22,21,64,21,64,21,64,21,64,21,64,21,64,21,64,21,64,21,64,21,64,21,22,21,22,21,22,21,22,21,64,21,22,21,22,21,22,21,64,21,64,21,64,21,64,21,22,21,64,21,4833"
WshShell.SendKeys ("{Enter}")
Sleep 1
WshShell.SendKeys "sendir,1:1,5,37764,1,1,340,168,21,22,21,22,21,22,21,22,21,22,21,22,21,22,21,22,21,64,21,64,21,64,21,64,21,64,21,64,21,64,21,64,21,64,21,22,21,64,21,22,21,22,21,22,21,22,21,22,21,22,21,64,21,22,21,64,21,64,21,64,21,64,21,64,21,4833"
WshShell.SendKeys ("{Enter}")
Sleep 1
WshShell.SendKeys "sendir,1:1,11,37764,1,1,340,168,21,22,21,22,21,22,21,22,21,22,21,22,21,22,21,22,21,64,21,64,21,64,21,64,21,64,21,64,21,64,21,64,21,22,21,64,21,64,21,64,21,64,21,22,21,64,21,22,21,64,21,22,21,22,21,22,21,22,21,64,21,22,21,64,21,4833"
WshShell.SendKeys ("{Enter}")
Sleep 1
WshShell.SendKeys "sendir,1:1,1,37764,1,1,340,168,21,22,21,22,21,22,21,22,21,22,21,22,21,22,21,22,21,64,21,64,21,64,21,64,21,64,21,64,21,64,21,64,21,22,21,64,21,22,21,64,21,22,21,22,21,22,21,22,21,64,21,22,21,64,21,22,21,64,21,64,21,64,21,64,21,4833"
WshShell.SendKeys ("{Enter}")
Sleep 1
WshShell.SendKeys ("^{]}q{Enter}exit{Enter}")
End Sub