Jump to content

Need help with my ping script


 Share

Recommended Posts

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
Link to comment
Share on other sites

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
Link to comment
Share on other sites

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:

Link to comment
Share on other sites

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.

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