Jump to content
Sign in to follow this  
XxxKills

Qestion regarding netstat

Recommended Posts

XxxKills

Ok, I'm haveing trouble fiquereing out how to write this the correct way. heres the code I'm working with take a look and tell me what you think.

WinSetState("Diablo II", "", @SW_HIDE) ;minimize game
Sleep(2000)
WinSetState("C:\WINDOWS\system32\cmd.exe", "", @SW_SHOW); opens cmd
WinActivate("C:\WINDOWS\system32\cmd.exe", "")
Sleep(1000)
Send("_netstat")
Sleep(1000)
Send("{ENTER}")
Sleep(1000)
FileOpen("Netstat", 2)
FileWriteLine("Netstat", "")               <------ this is where im haveing trouble(not sure what to add to get the correct line to write, 40000)
WinSetState("C:\WINDOWS\system32\cmd.exe", "", @SW_HIDE)
Sleep(2000)
WinSetState("Diablo II", "", @SW_SHOW)
WinActivate("Diablo II", "")
Sleep(2000)
;Do actions, else

Not sure what to do. I just want it to write the line of the :4000 string.

Any one know what to do?

I searched the help files and searched on the forums. I've found some examples. But not done in the way I need.

Thank you in advance for your time!

Share this post


Link to post
Share on other sites
BrettF
XxxKills

No, not exactly, thats not what I'm looking for, trying to write it to a file, but just that line and nothing else.

Share this post


Link to post
Share on other sites
nguyenbason

What do you mean by

I just want it to write the line of the :4000 string.


UnderWorldVN- Just play the way you like it

Share this post


Link to post
Share on other sites
BrettF
geocine

Is Netstat a text file?


Do Not Steal The Government Hates CompetitionO2JAM AutoPlayBot [|||||.............] 10%Friendster Commenter [..................] 0%Auto Message Download Percentage [|||||||||||||||||] 100%

Share this post


Link to post
Share on other sites
herewasplato

Where you see port ":80 " - change that to ":4000 "

#include <string.au3>

$PID = Run("netstat -n", @SystemDir, @SW_HIDE, 2)
Local $Out, $IParray

While 1
    $Out &= StdoutRead($PID)
    If @error Then ExitLoop
WEnd

$OutArray = StringSplit($Out, @CR)

For $i = 1 To $OutArray[0]
    If StringInStr($OutArray[$i], ":80 ", 1) Then
        MsgBox(0, $i & " of " & $OutArray[0], $OutArray[$i], 3)
        $IParray = _StringBetween($OutArray[$i], ":", ":")
        MsgBox(0, $i & " of " & $OutArray[0], ">>>" & _
                StringTrimLeft($IParray[0], 9) & "<<<", 3)
    EndIf
Next
This code is from something else.

I'll let the gamers help you with putting it in a file if you really think that you want it there.


[size="1"][font="Arial"].[u].[/u][/font][/size]

Share this post


Link to post
Share on other sites
herewasplato

Is Netstat a text file?

In these lines it is...

FileOpen("Netstat", 2)

FileWriteLine("Netstat", "")

...just no ".txt" file extension.


[size="1"][font="Arial"].[u].[/u][/font][/size]

Share this post


Link to post
Share on other sites
herewasplato

What do you mean by

It is the port of interest from the netstat output.

[size="1"][font="Arial"].[u].[/u][/font][/size]

Share this post


Link to post
Share on other sites
XxxKills

Where you see port ":80 " - change that to ":4000 "

#include <string.au3>

$PID = Run("netstat -n", @SystemDir, @SW_HIDE, 2)
Local $Out, $IParray

While 1
    $Out &= StdoutRead($PID)
    If @error Then ExitLoop
WEnd

$OutArray = StringSplit($Out, @CR)

For $i = 1 To $OutArray[0]
    If StringInStr($OutArray[$i], ":80 ", 1) Then
        MsgBox(0, $i & " of " & $OutArray[0], $OutArray[$i], 3)
        $IParray = _StringBetween($OutArray[$i], ":", ":")
        MsgBox(0, $i & " of " & $OutArray[0], ">>>" & _
                StringTrimLeft($IParray[0], 9) & "<<<", 3)
    EndIf
Next
This code is from something else.

I'll let the gamers help you with putting it in a file if you really think that you want it there.

This works great (thank you by the way, so great I rewrote my code to use yours instead lol) but when I try to write it back to the character screen it gives me nothing.

FileOpen("Netstat.txt", 2)
FileWriteLine("Netstat.txt","Netstat=" & $OutArray[$i])
FileClose("Netstat.txt")
    EndIf
Next
Sleep(2000)
    WinSetState("Diablo II", "", @SW_SHOW)
    WinActivate("Diablo II", "")
    Sleep(4000)
    FileReadLine("Netstat", 2)
Send("{ENTER}")
Sleep(5000)
Send($Netstat,"")
Send("{ENTER}")
Sleep(5000)

I cant find in the help files where to only write the line in the file to the diablo screen. I know I'm missing something, and its probably something simple. can some one point me in the right direction on this.

Edited by XxxKills

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  

×