Jump to content
Sign in to follow this  

Monitor Connection

Recommended Posts

i did pixelgetcolor before and is not working like i wanted it.. this time i want to manage by IP since the program is connected online.

I found this script and it worked great by pulling the IP address.

What i want to do is compare the ip address

for example

if outlook ip =




run taskkill outlook.exe

run outlook.exe

end if


#include <Constants.au3>

$proc = "Outlok.exe" ; change this to the process you want to monitor

$list = ProcessList($proc)

If $list[0][0] = 0 Then

MsgBox(0, "Error", " The " & $proc & " process is not running")



For $i = 1 To $list[0][0]

$pid = $list[$i][1]


$cmd = "netstat -ano"

$string = _CMDreturn($cmd)

;split the string into an array of individual lines for processing

$result = StringSplit($string, @CR)

;process the array

For $x = 1 To $result[0]

$line = $result[$x]

;get rid of extra white space

$newline = StringStripWS($line, 4)

;strip leading @LF characters from the results

If StringMid($newline, 1, 1) = @LF Then $newline = StringTrimLeft($newline, 1)

;split the line into another array so we can compare just the PIDs

$a_line = StringSplit($newline, " ")

If $a_line[0] = 5 Then ;only look at lines that had 5 pieces of info

If $a_line[5] = $pid Then MsgBox(0, "Results", "PID=" & $a_line[5] & @CRLF & "IP=" & $a_line[3])



Func _CMDreturn($sCommand) ; Returns the output of a DOS command as a string

$cmdreturn = ""

$stream = Run(@ComSpec & " /c " & $sCommand, @SystemDir, @SW_HIDE, $STDOUT_CHILD + $STDIN_CHILD)

While 1 ; loop through the return from the command until there is no more

$line = StdoutRead($stream)

If @error Then ExitLoop

$cmdreturn &= $line


Return $cmdreturn

EndFunc ;==>_CMDreturn

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  

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Create New...