Sign in to follow this  
Followers 0
st4vr0s

Ping script and move window problems

5 posts in this topic

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?

CODE
Run ("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

Share this post


Link to post
Share on other sites



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

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

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):

Posted Image

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0