st4vr0s Posted June 9, 2009 Posted June 9, 2009 Hello all, I'm trying to write a basic script that will open 4 cmd windows, ping 4 ip's and moves windows. For some reason as soon as the first enter is pressed mulitple CMD windows are opened. What am I missing here? CODERun ("C:\Windows\System32\cmd.exe") WinWait ("Administrator: C:\Windows\System32\cmd.exe") WinActivate ("Administrator: C:\Windows\System32\cmd.exe") WinWaitActive ("Administrator: C:\Windows\System32\cmd.exe") Send ("ping 192.168.0.250 -t") Sleep (500) Send ("{ENTER}") WinMove ("Administrator: C:\Windows\System32\cmd.exe - ping 192.168.0.250 -t", "", 0, 1) Run ("C:\Windows\System32\cmd.exe") Sleep (500) Send ("ping 192.168.1.250 -t") Sleep (500) Send ("{ENTER}") WinMove("Administrator: C:\Windows\System32\cmd.exe - ping 192.168.1.250 -t", "", 677, 1) Run ("C:\Windows\System32\cmd.exe") Sleep (500) Send ("ping 192.168.0.254 -t") Sleep (500) Send ("{ENTER}") WinMove("Administrator: C:\Windows\System32\cmd.exe - ping 192.168.0.254 -t", "", 0, 341) Run ("C:\Windows\System32\cmd.exe") Sleep (500) Send ("ping 192.168.1.254 -t") Sleep (500) Send ("{ENTER}") WinMove("Administrator: C:\Windows\System32\cmd.exe - ping 192.168.1.254 -t", "", 677, 341) Thanks
BrettF Posted June 9, 2009 Posted June 9, 2009 AutoIt has Ping built native... Why not use that? Vist my blog!UDFs: Opens The Default Mail Client | _LoginBox | Convert Reg to AU3 | BASS.au3 (BASS.dll) (Includes various BASS Libraries) | MultiLang.au3 (Multi-Language GUIs!)Example Scripts: Computer Info Telnet Server | "Secure" HTTP Server (Based on Manadar's Server)Software: AAMP- Advanced AutoIt Media Player | WorldCam | AYTU - Youtube Uploader Tutorials: Learning to Script with AutoIt V3Projects (Hardware + AutoIt): ArduinoUseful Links: AutoIt 1-2-3 | The AutoIt Downloads Section: | SciTE4AutoIt3 Full Version!
st4vr0s Posted June 9, 2009 Author Posted June 9, 2009 AutoIt has Ping built native... Why not use that?Because I need it to display constant ping times in a Command prompt window for up to 30 minutes at a time.Do you know why it may keep opening a fresh window when it gets to the enter stage and only stops if I pause script?Thanks
dillonlim Posted June 9, 2009 Posted June 9, 2009 I did something similar awhile back and I used AutoIt's native ping and this was what I came up with. Hope it helps. HotKeySet("{ESC}", "Terminate") $ip = InputBox("Ping Type Thing", "IP Address:", "", "", 200, 60) If @Error Then Exit Local $count = 0 Local $success = 0 $display = 'Pinging "' & $ip & '"' SplashTextOn("Ping Type Thing", $display, 650, 45, -1, 5, 48) While 1 $count = $count + 1 $pingresult = Ping($ip, 50) If $pingresult > "0" Then $success = $success + 1 EndIf $percentage = ($success / $count) * 100 $ppacketloss = 100 - $percentage ControlSetText("Ping Type Thing", "", "Static1", $display & ". " & $pingresult & " ms response time and " & Round($ppacketloss, 2) & "% packet loss.") Sleep(50) WEnd SplashOff() Func Terminate() Exit 0 EndFunc Because I need it to display constant ping times in a Command prompt window for up to 30 minutes at a time. Do you know why it may keep opening a fresh window when it gets to the enter stage and only stops if I pause script? Thanks
kardain Posted December 16, 2009 Posted December 16, 2009 So this is 6 months after the fact, but your question was left unanswered, registered just to 1) provide a potential solution to your question and 2) thank dillonlim for an example to help "pretty up" a script I have on my machine for IP release/refresh.I was able to get AutoIT to move the windows into a grid pattern after altering your code slightly, which I am assuming was the goal. Note: I am using Win Vista...On all instances of WinMove, instead of using "Administrator: C:\Windows\System32\cmd.exe - ping 192.168.1.254 -t", I got it to work by reducing it to as follows (change numbers as required):WinMove("Administrator", "", 677, 341)End result (click for fullsize):
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now