Sign in to follow this  
Followers 0
Kage

Ping tool

4 posts in this topic

#1 ·  Posted (edited)

Hello!

i have been attempting to make a easy ping tool for myself.

i found someone else's ping tool and wanted to build it in a GUI

Right now the pinging works, but i cannot seems to have 2 pings run at the same time.

i was hoping if someone could help me with it.

The idea is to click a check box and a ping start running, in the script below i have only wrote it for the checkbox of Premiums01 and premiums02 when you uncheck the checkbox it stops pinging

Right now the ping target is set on google.com

i hope someone could tell me if its possible what im trying to achieve

im still rather new to autoit so please give me feedback! :x

#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

start()

Func start()


    GUICreate("Ping tool", 400, 200)
        $ping1 = GUICtrlCreateInput("Custom Target 1", 40, 40, 100, 21)
        GUICtrlSetState($ping1, $gui_disable)
        $ping1d = GUICtrlCreateCheckbox(" ",10, 40)

        $ping2 = GUICtrlCreateInput("Custom Target 2", 40, 65, 100)
        GUICtrlSetState($ping2, $gui_disable)
        $ping2d = GUICtrlCreateCheckbox(" ",10, 65)

        $ping3 = GUICtrlCreateInput("Custom Target 3", 40, 90, 100)
        GUICtrlSetState($ping3, $gui_disable)
        $ping3d = GUICtrlCreateCheckbox(" ",10, 90)
        
        $ping4 = GUICtrlCreateInput("Custom Target 4", 40, 115, 100)
        GUICtrlSetState($ping4, $gui_disable)
        $ping4d = GUICtrlCreateCheckbox(" ",10, 115)
        
        $pingprS01 = GUICtrlCreateCheckbox("Premiums01", 160, 60)
        $pinggoogle = GUICtrlCreateCheckbox("Google", 160, 40)
        $pingprS02 = GUICtrlCreateCheckbox("Premiums02", 160, 80)
        $pingprS03 = GUICtrlCreateCheckbox("Premiums03", 160, 100)
        $pingprS04 = GUICtrlCreateCheckbox("Premiums04", 160, 120)
        $pingprS05 = GUICtrlCreateCheckbox("Premiums05", 160, 140)

GUISetState() 


while 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            ExitLoop
        Case $msg = $ping1d ; ping input 1 disable
                If GUICtrlRead($ping1d) = 1 Then 
                    GUICtrlSetState($ping1, $GUI_ENABLE)
                Else
                    GUICtrlSetState($ping1, $GUI_DISABLE)
                EndIf
        Case $msg = $ping2d ; ping input 2 disable
                If GUICtrlRead($ping2d) = 1 Then 
                    GUICtrlSetState($ping2, $GUI_ENABLE)
                Else
                    GUICtrlSetState($ping2, $GUI_DISABLE)
                EndIf
        Case $msg = $ping3d ; ping input 3 disable
                If GUICtrlRead($ping3d) = 1 Then 
                    GUICtrlSetState($ping3, $GUI_ENABLE)
                Else
                    GUICtrlSetState($ping3, $GUI_DISABLE)
                EndIf
        Case $msg = $ping4d ; ping input 4 disable
                If GUICtrlRead($ping4d) = 1 Then 
                    GUICtrlSetState($ping4, $GUI_ENABLE)
                Else
                    GUICtrlSetState($ping4, $GUI_DISABLE)
                EndIf
        Case $msg = $pingprs01 ;ping premiums01
            If GUICtrlRead($pingprs01) = 1 Then

            Local $1count = 0
            Local $1success = 0
                
            $1display = 'Pinging "Premiums01"'
            SplashTextOn("Premiums01", $1display, 650, 45, -1, 5, 48)
                Do
                    $1count = $1count + 1
                    $1pingresult = Ping("google.com", 50)
                    If $1pingresult > "0" Then
                        $1success = $1success + 1
                    EndIf

                    $1percentage = ($1success / $1count) * 100
                    $1ppacketloss = 100 - $1percentage

                    ControlSetText("Premiums01", "", "Static1", $1display & ". " & $1pingresult & " ms response time and " & Round($1ppacketloss, 2) & "% packet loss.")
                    Sleep(50)
                Until GUICtrlRead($pingprs01) = 4
                SplashOff()
            EndIf
        Case $msg = $pingprs02 ;ping premiums02
            If GUICtrlRead($pingprs02) = 1 Then

            Local $2count = 0
            Local $2success = 0
                
            $2display = 'Pinging "Premiums02"'
            SplashTextOn("Ping Type Thing", $2display, 650, 45, -1, 5, 48)
                Do
                    $2count = $2count + 1
                    $2pingresult = Ping("google.com", 50)
                    If $2pingresult > "0" Then
                        $2success = $2success + 1
                    EndIf

                    $2percentage = ($2success / $2count) * 100
                    $2ppacketloss = 100 - $2percentage

                    ControlSetText("Ping Type Thing", "", "Static1", $2display & ". " & $2pingresult & " ms response time and " & Round($2ppacketloss, 2) & "% packet loss.")
                    Sleep(50)
                Until GUICtrlRead($pingprs02) = 4
                SplashOff()
            EndIf

    EndSelect
WEnd
EndFunc
Edited by Kage

Share this post


Link to post
Share on other sites



Share this post


Link to post
Share on other sites

That was not really wat i ment, i was wondering if it is possible to have 2 pings of those (that are in my script) to run at the same time.

Right now if you load the script and execute it the 2 checkboxes of premiums01 and premiums02 work, as they both ping to google, right now you can only use one of those at a time. and im looking for a way to have them both pinging at the same time

Share this post


Link to post
Share on other sites

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  
Followers 0