Jump to content
Sign in to follow this  
rikho

GUI ping interface

Recommended Posts

rikho

Hello all,

i try to make a ping interface with a visual result.

First of all i dont know how to code this

my first test is bellow, i want to do appear the GUI to make the server choice

Actually, the server ping is launch first and the GUI appear only next :D

sorry for my noobs question, i need help to learn to code.

thx for help.

#include <GUIConstants.au3>
$sbgui = GUICreate("GUI ping test", 351, 191, 340, 110)

$Label1 = GUICtrlCreateLabel("Select target server", 8, 8, 139, 17)
$Combo1 = GUICtrlCreateCombo("", 176, 8, 153, 120)
GUICtrlSetData(-1, "server1|server2")
GUICtrlSetResizing(-1, $GUI_DOCKWIDTH + $GUI_DOCKHEIGHT)

$ServerName = $Combo1
MsgBox(4096, "", $ServerName, 0)
$var = Ping($ServerName, 250)
If $var Then; also possible:  If @error = 0 Then ...
    MsgBox(0, "Status", "Serveur is responding")
Else
    MsgBox(0, "Status", "Serveur is not responding")
EndIf

GUICtrlSetFont(-1, 10, 400, 0, "Arial")
$MenuItem1 = GUICtrlCreateMenu("&File")
$MenuItem2 = GUICtrlCreateMenu("&help")
GUISetState(@SW_SHOW)

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit

    EndSwitch
WEnd
Edited by rikho

Share this post


Link to post
Share on other sites
kris06

Hello all,

i try to make a ping interface with a visual result.

First of all i dont know how to code this

my first test is bellow, i want to do appear the GUI to make the server choice

Actually, the server ping is launch first and the GUI appear only next :P

sorry for my noobs question, i need help to learn to code.

thx for help.

#include <GUIConstants.au3>
$sbgui = GUICreate("GUI ping test", 351, 191, 340, 110)

$Label1 = GUICtrlCreateLabel("Select target server", 8, 8, 139, 17)
$Combo1 = GUICtrlCreateCombo("", 176, 8, 153, 120)
GUICtrlSetData(-1, "server1|server2")
GUICtrlSetResizing(-1, $GUI_DOCKWIDTH + $GUI_DOCKHEIGHT)

$ServerName = $Combo1
MsgBox(4096, "", $ServerName, 0)
$var = Ping($ServerName, 250)
If $var Then; also possible:  If @error = 0 Then ...
    MsgBox(0, "Status", "Serveur is responding")
Else
    MsgBox(0, "Status", "Serveur is not responding")
EndIf

GUICtrlSetFont(-1, 10, 400, 0, "Arial")
$MenuItem1 = GUICtrlCreateMenu("&File")
$MenuItem2 = GUICtrlCreateMenu("&help")
GUISetState(@SW_SHOW)

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit

    EndSwitch
WEnd

Hope this helps :D!!

remember, you cannot read a value directly used in a GUI container.

GUICtrlRead will help u acheive that.

Rgds,

kris

#include <GUIConstants.au3>
$sbgui = GUICreate("GUI ping test", 351, 191, 340, 110)

$Label1 = GUICtrlCreateLabel("Select target server", 8, 8, 139, 17)
$Combo1 = GUICtrlCreateCombo("", 176, 8, 153, 120)
GUICtrlSetData(-1, "Server1|Server2"); Replace with the actual IP addr or FQDN
GUICtrlSetResizing(-1, $GUI_DOCKWIDTH + $GUI_DOCKHEIGHT)
$pingbutton=GUICtrlCreateButton("Ping", 110, 140, 100)
$ServerName = $Combo1

GUICtrlSetFont(-1, 10, 400, 0, "Arial")
$MenuItem1 = GUICtrlCreateMenu("&File")
$MenuItem2 = GUICtrlCreateMenu("&help")
GUISetState(@SW_SHOW)

While 1
    $Msg = GUIGetMsg()
    Select 
        Case $Msg = $GUI_EVENT_CLOSE
            Exit
        Case $Msg = $pingbutton; On click event button, pingbutton
        
                MsgBox(4096, "Server Selected", GUICtrlRead($ServerName), 20)
                $var = Ping(GUICtrlRead($ServerName), 250)
    
                If $var Then; also possible:  If @error = 0 Then ...
                MsgBox(0, "Status", "Server online. RS delay: " & $var)
          Else
                MsgBox(0, "Status", "Server is offline. Error Code: " & @error)
                
                EndIf
    

        

  EndSelect
WEnd

Share this post


Link to post
Share on other sites
rikho

Hope this helps :D!!

remember, you cannot read a value directly used in a GUI container.

GUICtrlRead will help u acheive that.

Rgds,

kris

#include <GUIConstants.au3>
$sbgui = GUICreate("GUI ping test", 351, 191, 340, 110)

$Label1 = GUICtrlCreateLabel("Select target server", 8, 8, 139, 17)
$Combo1 = GUICtrlCreateCombo("", 176, 8, 153, 120)
GUICtrlSetData(-1, "Server1|Server2"); Replace with the actual IP addr or FQDN
GUICtrlSetResizing(-1, $GUI_DOCKWIDTH + $GUI_DOCKHEIGHT)
$pingbutton=GUICtrlCreateButton("Ping", 110, 140, 100)
$ServerName = $Combo1

GUICtrlSetFont(-1, 10, 400, 0, "Arial")
$MenuItem1 = GUICtrlCreateMenu("&File")
$MenuItem2 = GUICtrlCreateMenu("&help")
GUISetState(@SW_SHOW)

While 1
    $Msg = GUIGetMsg()
    Select 
        Case $Msg = $GUI_EVENT_CLOSE
            Exit
        Case $Msg = $pingbutton; On click event button, pingbutton
        
                MsgBox(4096, "Server Selected", GUICtrlRead($ServerName), 20)
                $var = Ping(GUICtrlRead($ServerName), 250)
    
                If $var Then; also possible:  If @error = 0 Then ...
                MsgBox(0, "Status", "Server online. RS delay: " & $var)
          Else
                MsgBox(0, "Status", "Server is offline. Error Code: " & @error)
                
                EndIf
    

        

  EndSelect
WEnd

Thank you !

ps : i will remember :P

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  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.