Jump to content

up to date ping


Recommended Posts

how to make up to date ping?

i make a script to know connections from user to server.

this my script.

#include <GUIConstantsEx.au3>
#include <Array.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <SendMessage.au3>
Box()


Func Box()
   
    Local $msg
   
   GUICreate("iSerius", 260, 85, 1093, 625)
   GUICtrlCreateLabel("iSerius : ", 5, 5, 100, 36)
   $btnCon = GUICtrlCreateButton("Connect", 10, 50, 50, 25, 0)
   $btnDC = GUICtrlCreateButton("Disconnect", 62, 50, 75, 25, 0)
   $btnMCE = GUICtrlCreateButton("MCE", 190, 50, 40, 25, 0)
  
  
  
   GUISetState()
   
  
    While 1
    If Ping("google.com", 1000) Then
   GUICtrlCreateLabel("UP", 40, 5, 100, 36)
    Else
   GUICtrlCreateLabel("DOWN", 40, 5, 100, 36)
    EndIf
        $msg = GUIGetMsg()
        Select
            Case $msg = $GUI_EVENT_CLOSE
                Exit
            Case $msg = $GuI_EVENT_MINIMIZE
               
   Case $msg = $GUI_EVENT_MAXIMIZE
   
   Case $msg = $btnCon
                run("rasphone -d iSerius")
  
   Case $msg = $btnDC
                run("rasdial /DISCONNECT")
   
   Case $msg = $btnMCE
                run("explorer.exe \\10.1.1.1")
           
        EndSelect
    WEnd
EndFunc   ;end box()

at my script ping google just for test.

when i try disconnect i stack between "up" and "down".

how to make it like up to date server information?

when down,its text "down"..

and when up give text "up"

Link to comment
Share on other sites

GUICtrlCreateLabel creates a label

GUICtrlSetData updates the text of a previously created label (or other controls)

you are creating thousands of new controls the longer your script runs.

also you ping spam the website with no delay between the pings.

added a timer which pings only every second and fixed updating the label:

#include <GUIConstantsEx.au3>
#include <Array.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <SendMessage.au3>
Box()


Func Box()

    Local $msg

    GUICreate("iSerius", 260, 85, 1093, 625)
    GUICtrlCreateLabel("iSerius : ", 5, 5, 100, 36)
    $btnCon = GUICtrlCreateButton("Connect", 10, 50, 50, 25, 0)
    $btnDC = GUICtrlCreateButton("Disconnect", 62, 50, 75, 25, 0)
    $btnMCE = GUICtrlCreateButton("MCE", 190, 50, 40, 25, 0)
    $lStatus = GUICtrlCreateLabel("UP", 40, 5, 100, 36)


    GUISetState()

    $ti = TimerInit()
    While 1

        If TimerDiff($ti) > 1000 then
            $ti = TimerInit()
            If Ping("google.com", 1000) Then
                GUICtrlSetData($lStatus,"UP")
            Else
                GUICtrlSetData($lStatus,"DOWN")
            EndIf
        EndIf

        $msg = GUIGetMsg()
        Select
            Case $msg = $GUI_EVENT_CLOSE
                Exit
            Case $msg = $GuI_EVENT_MINIMIZE

            Case $msg = $GUI_EVENT_MAXIMIZE

            Case $msg = $btnCon
                Run("rasphone -d iSerius")

            Case $msg = $btnDC
                Run("rasdial /DISCONNECT")

            Case $msg = $btnMCE
                Run("explorer.exe 10.1.1.1")

        EndSelect

    WEnd
EndFunc   ;==>Box
Edited by qsek
Teamspeak 3 User Viewer - Quick and functional TS3 Query script, which shows online users.Cached Screenshot Deleter - Deletes older Fraps Screenshots if they exceed a specified limit.Unresolved Topics:Intercept and modify dragdrop text behaviour in scite
Link to comment
Share on other sites

GUICtrlCreateLabel creates a label

GUICtrlSetData updates the text of a previously created label (or other controls)

you are creating thousands of new controls the longer your script runs.

also you ping spam the website with no delay between the pings.

added a timer which pings only every second and fixed updating the label:

#include <GUIConstantsEx.au3>
#include <Array.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <SendMessage.au3>
Box()


Func Box()

    Local $msg

    GUICreate("iSerius", 260, 85, 1093, 625)
    GUICtrlCreateLabel("iSerius : ", 5, 5, 100, 36)
    $btnCon = GUICtrlCreateButton("Connect", 10, 50, 50, 25, 0)
    $btnDC = GUICtrlCreateButton("Disconnect", 62, 50, 75, 25, 0)
    $btnMCE = GUICtrlCreateButton("MCE", 190, 50, 40, 25, 0)
    $lStatus = GUICtrlCreateLabel("UP", 40, 5, 100, 36)


    GUISetState()

    $ti = TimerInit()
    While 1

        If TimerDiff($ti) > 1000 then
            $ti = TimerInit()
            If Ping("google.com", 1000) Then
                GUICtrlSetData($lStatus,"UP")
            Else
                GUICtrlSetData($lStatus,"DOWN")
            EndIf
        EndIf

        $msg = GUIGetMsg()
        Select
            Case $msg = $GUI_EVENT_CLOSE
                Exit
            Case $msg = $GuI_EVENT_MINIMIZE

            Case $msg = $GUI_EVENT_MAXIMIZE

            Case $msg = $btnCon
                Run("rasphone -d iSerius")

            Case $msg = $btnDC
                Run("rasdial /DISCONNECT")

            Case $msg = $btnMCE
                Run("explorer.exe 10.1.1.1")

        EndSelect

    WEnd
EndFunc   ;==>Box

thanks sir,,

actualy i ever make delay but use "sleep", and make my script not respond..

thanks for knowledge.

i know time function now ;)

Edited by historyoftheday
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...