Jump to content

Little Script To Give Netstat Info, Possible?


Recommended Posts

I'm more or less wondering if this is even possible. Some background this is for a game and on different servers a special event happens from time to time, I need to know while in game if Im connected to the right server. Here are the manual steps"

1) I create a game on a server, then tab back to windows.

2) Click "Start then "Run" and type "command"

3) At the prompt I type netstat - n

4) I look for a IP that ends in 4000 so it is like this 123.255.123.XXX:4000

5) The XXX is the numbers I need to check if Im on the correct server. If it is the right number I stay if not I make another game and repeated.

What I would like to do is have a script that would idle till I kicked it off with say [F12]. When [F12] is pressed the scripts would run netstat find the IP that ends in 4000 then display the XXX it in my current screen or type it in the game chat system. It would not be necessary for the script to cut down to IP to just the numbers I need but would make it cleaner.

I'm not asking anyone here to do anything for me I have time this weekend to play with it, I'm just curious if Autoit has the capability to do what Im looking for here, such as run netstat without displaying anything on the screen, or lay text on the screen over a full screen game.

Thanks guys :)

Edit: I was thinking I was in the support forum, feel free to kick the noob :mellow: If this needs to be deleted or moved I'm sorry.

Edited by d2a007
Link to comment
Share on other sites

#include <Constants.au3>
Func _GetD2Ip()
    $foo = Run(@ComSpec & " /c netstat -n", @SystemDir, @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD)
    $line = StdoutRead($foo)
    $var = StringSplit($line, @LF)
    For $i = 0 To UBound($var, 1) - 1
        If StringInStr($var[$i], ":") And StringInStr($var[$i], "4000") Then
            $va = StringInStr($var[$i], ":", 0, 2)
            $var[$i] = StringReplace($var[$i], 'tcp', '')
            $var[$i] = StringReplace($var[$i], 'ESTABLISHED', '')
            $var[$i] = StringReplace($var[$i], 'TIME_WAIT', '')
            $var[$i] = StringReplace($var[$i], ' ', '')
            $var[$i] = StringReplace($var[$i], '63.240.202.', '')
            $var[$i] = StringReplace($var[$i], "4000", '')
            $var[$i] = StringReplace($var[$i], ':', '')
            $var[$i] = StringReplace($var[$i], @IPAddress1, '')
            $var[$i] = StringTrimLeft($var[$i], 4)
            Return $var[$i]
        EndIf
    Next
EndFunc ;==>_GetD2Ip

This is a function i had written up, it returns the last 2 to 3 digits of your current diablo II ip

so say ur in

nn.nn.nn.123

it returns 123

or if your in

nn.nn.nn.95

it returns 95

~cdkid

Edited by cdkid
AutoIt Console written in C#. Write au3 code right at the console :D_FileWriteToLineWrite to a specific line in a file.My UDF Libraries: MySQL UDF Library version 1.6 MySQL Database UDF's for AutoItI have stopped updating the MySQL thread above, all future updates will be on my SVN. The svn location is:kan2.sytes.net/publicsvn/mysqlnote: This will still be available, but due to my new job, and school hours, am no longer developing this udf.My business: www.hirethebrain.com Hire The Brain HireTheBrain.com Computer Consulting, Design, Assembly and RepairOh no! I've commited Scriptocide!
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...