Jump to content

Online/Offline


Recommended Posts

Hey guys, I need some help to solve this.. I'm trying to test if a server (gameserver) is online/offline.. but i really dont know what to do.. my code is this

#include <GUIConstants.au3>
GUICreate("WOW-Brasil Checker 1.0",250,60)
GUISetState ()
$i=GUICtrlCreateInput("wowbrasil.servegame.com",1,1,200,20)
$t=GUICtrlCreateButton("Teste",201,1,40,20)
$te=GUICtrlCreateLabel("Status:",1,30,50,20)
$te=GUICtrlCreatePic("",51,30,16,16)
While 1
    $msg = GUIGetMsg()
    $read=guictrlread($i)
If $msg=$t Then
    $p=Ping($read,300)
    If $p>0 Then
            GUICtrlSetImage($te,"online.gif")
        Else
            GUICtrlSetImage($te,"offline.gif")
    EndIf
EndIf
    
    If $msg = $GUI_EVENT_CLOSE Then ExitLoop
        
Wend

(yea its a noobish code) but the problem is that will Ping.. and will ping the website.. i want to "get the answer" from the server (that uses another port, of course).

Could you help?

Thanks!

Link to comment
Share on other sites

Works for me:

I moved a line, extended the wait of the ping, and used text instead of your images... as I didn't have them handy

#include <GUIConstants.au3>
GUICreate("WOW-Brasil Checker 1.0", 250, 60)
GUISetState()
$i = GUICtrlCreateInput("wowbrasil.servegame.com", 1, 1, 200, 20)
$t = GUICtrlCreateButton("Teste", 201, 1, 40, 20)
$te = GUICtrlCreateLabel("Status:", 1, 30, 50, 20)

While 1
    $msg = GUIGetMsg()
    If $msg = $t Then
        $read = GUICtrlRead($i)
        $p = Ping($read, 3000)
        If $p > 0 Then
            GUICtrlSetData($te, "Status = Online")
        Else
            GUICtrlSetData($te, "Status = Offline")
        EndIf
    EndIf
    If $msg = $GUI_EVENT_CLOSE Then ExitLoop
WEnd
Edited by SpookMeister

[u]Helpful tips:[/u]If you want better answers to your questions, take the time to reproduce your issue in a small "stand alone" example script whenever possible. Also, make sure you tell us 1) what you tried, 2) what you expected to happen, and 3) what happened instead.[u]Useful links:[/u]BrettF's update to LxP's "How to AutoIt" pdfValuater's Autoit 1-2-3 Download page for the latest versions of Autoit and SciTE[quote]<glyph> For example - if you came in here asking "how do I use a jackhammer" we might ask "why do you need to use a jackhammer"<glyph> If the answer to the latter question is "to knock my grandmother's head off to let out the evil spirits that gave her cancer", then maybe the problem is actually unrelated to jackhammers[/quote]

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...