Jump to content
Sign in to follow this  
GtHoo

Need help with my ping script

Recommended Posts

GtHoo

Hi, i can't get my ping script to work. Can someone help me?

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

GUICreate("Pinger", 200, 100)  ; Lager viduet.
$start = GUICtrlCreateButton("ping", 70, 70, 70) ;Lager knappen.
GUICtrlCreateLabel ("Ping adressen:", 20, 10) ; Lager en label
$url = GUICtrlCreateInput (" ", 20, 30, 150)
GUISetState(@SW_SHOW) ; Gjør så vinduet ikke lukker seg.

While 1
$msg = GUIGetMsg()
  Select
  
    Case $msg = $start ;gjør så "Vinduet" sine knapper skal fungere
    
       Local $ping = ping ("$url", 250)
      
       If $ping Then
      
        MsgBox(0, "Ping", "Pingen er " & $ping)
      
       Else
        MsgBox(0, "Error", "error", @error)
       EndIf
      
        Case $msg = $GUI_EVENT_CLOSE
        
        ExitLoop
      
EndSelect  
WEnd

Share this post


Link to post
Share on other sites
ZacUSNYR

No point in declaring it local since it'll be in the global scope. Although that has no effect on the script. Just a good FYI..

Local $ping = ping ("$url", 250)

Replace that with

$ping = ping (GUICtrlRead($url), 250)

You need to read the input which is what GUICtrlRead does.

Share this post


Link to post
Share on other sites
GtHoo

I have edited it like you did say, but I still can't get it to work.

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

GUICreate("Pinger", 200, 100)  ; Lager viduet.
$start = GUICtrlCreateButton("ping", 70, 70, 70) ;Lager knappen.
GUICtrlCreateLabel ("Ping adressen:", 20, 10) ; Lager en label
$url = GUICtrlCreateInput (" ", 20, 30, 150)
GUISetState(@SW_SHOW) ; Gjør så vinduet ikke lukker seg.

While 1
$msg = GUIGetMsg()
  Select
  
    Case $msg = $start ;gjør så "Vinduet" sine knapper skal fungere
    
       Global $ping = ping (GUICtrlRead ($url), 250)
      
       If $ping Then
      
        MsgBox(0, "Ping", "Pingen er " & $ping)
      
       Else
        MsgBox(0, "Error", "error", @error)
       EndIf
      
        Case $msg = $GUI_EVENT_CLOSE
        
        ExitLoop
      
EndSelect  
WEnd

Share this post


Link to post
Share on other sites
GtHoo

what address are you pinging? maybe remove the www and look for unwanted characters

I was trying google.com, facebook.com and some other sites, but it works now.

It works with www.

Thank you for the help :oops:

Share this post


Link to post
Share on other sites
ZacUSNYR

I'm guessing your issue was the blank in the Input? I tested what you had posted and I was clicking in the input field, nothing worked. Because there was a leading blank created by the line

$url = GUICtrlCreateInput (" ", 20, 30, 150)

Brought up the GUI - back spaced after clicking - worked.

Changing that to

$url = GUICtrlCreateInput ("", 20, 30, 150)

Solved that issue.

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  

×