我从.bat脚本调用7个vbscripts来启动与7个Android Emulators的Telnet会话。问题是最终所有vbscripts都写入同一个Telnet会话。我是脚本新手,所以请帮助。
begin.bat
setlocal enabledelayedexpansion
FOR /L %%G IN (1,1,7) DO (
::start emulator
emulator -avd em%%G
:: Open a Telnet window
timeout /t 60 /nobreak >NUL
set /A "_myport= 5552+2*%%G"
timeout /t 1 /nobreak >NUL
telnet.exe localhost !_myport!
::run script
cscript SendKeys.vbs)
SendKeys.vbs
set OBJECT=WScript.CreateObject("WScript.Shell")
WScript.sleep 50
Dim max,min
max=100
min=1
Randomize
battery_level= Int((max-min+1)*Rnd+min)
OBJECT.SendKeys "power capacity "
OBJECT.SendKeys battery_level
OBJECT.SendKeys "{ENTER}"
'Xml stuff for getting the coordinates
Set objXML = CreateObject("Microsoft.XMLDOM")
objXML.async = False
objXML.Load ("C:\Users\basilhs\Downloads\alimos-omonoia.xml")
Set point = objXML.getElementsByTagName("trkpt")
For i = 0 To point.length - 1
Set subNodes = point(i)
OBJECT.SendKeys "geo fix "
OBJECT.SendKeys subNodes.getAttribute("lon")
OBJECT.SendKeys " "
OBJECT.SendKeys subNodes.getAttribute("lat")
OBJECT.SendKeys "{ENTER}"
WScript.Sleep 5000
Next
OBJECT.SendKeys "exit{ENTER}"
答案 0 :(得分:0)
查找AppActivate
set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.Run "calc"
WshShell.Run "notepad"
WScript.Sleep 100
Msgbox WshShell.AppActivate("Save As")
WScript.Sleep 100
Msgbox WshShell.AppActivate("Calculator")
WScript.Sleep 100
Msgbox WshShell.AppActivate("Notepad")
WScript.Sleep 100
Msgbox WshShell.AppActivate("Calculator")
WScript.Sleep 100
这是另一个样本
set WshShell = WScript.CreateObject("WScript.Shell")
If WSHShell.AppActivate("Calculator")=False then
WshShell.Run "C:\windows\System32\calc.exe", 1, false
End If