Jump to content

Recommended Posts

Posted

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
Posted

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.

Posted

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
Posted

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:

Posted

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.

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
×
×
  • Create New...