Sign in to follow this  
Followers 0
au3scr

Ping problem

5 posts in this topic

Hi i am trying to make ping program , but it dont work. I get error 4 when i press ping button.

Can some one help me at here?

#include <GUIConstants.au3>

#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Ping", 300, 40)
$ping = GUICtrlCreateInput ("",3,1,294,18)
$btn = GUICtrlCreateButton ("Ping",130,21,50,18)
GUISetState(@SW_SHOW)

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $btn
            Pingit ()
    EndSwitch
WEnd

Func Pingit ()
$readaddress = GUICtrlRead ($ping)  
$var = Ping("http://"&$ping,250)
If $var Then; also possible:  If @error = 0 Then ...
    Msgbox(0,"Status","Online, roundtrip was:" & $var)
Else
    Msgbox(0,"Status","An error occured with number: " & @error)
EndIf
EndFunc

Is it possible to resolve IP to Address and Address to IP ?


Share this post


Link to post
Share on other sites

I dont think you want Http:// inside your ping statement


[u]Helpful tips:[/u]If you want better answers to your questions, take the time to reproduce your issue in a small "stand alone" example script whenever possible. Also, make sure you tell us 1) what you tried, 2) what you expected to happen, and 3) what happened instead.[u]Useful links:[/u]BrettF's update to LxP's "How to AutoIt" pdfValuater's Autoit 1-2-3 Download page for the latest versions of Autoit and SciTE[quote]<glyph> For example - if you came in here asking "how do I use a jackhammer" we might ask "why do you need to use a jackhammer"<glyph> If the answer to the latter question is "to knock my grandmother's head off to let out the evil spirits that gave her cancer", then maybe the problem is actually unrelated to jackhammers[/quote]

Share this post


Link to post
Share on other sites

use this

Func Pingit ()
$readaddress = GUICtrlRead ($ping)  
$var = Ping($readaddress,250)
If @error = 0 Then 
    Msgbox(0,"Status","Online, roundtrip was:" & $var)
Else
    Msgbox(0,"Status","An error occured with number: " & @error)
EndIf
EndFunc

Share this post


Link to post
Share on other sites

Actually I think you want you Ping line to look more like this:

$var = Ping($readaddress,250)

[u]Helpful tips:[/u]If you want better answers to your questions, take the time to reproduce your issue in a small "stand alone" example script whenever possible. Also, make sure you tell us 1) what you tried, 2) what you expected to happen, and 3) what happened instead.[u]Useful links:[/u]BrettF's update to LxP's "How to AutoIt" pdfValuater's Autoit 1-2-3 Download page for the latest versions of Autoit and SciTE[quote]<glyph> For example - if you came in here asking "how do I use a jackhammer" we might ask "why do you need to use a jackhammer"<glyph> If the answer to the latter question is "to knock my grandmother's head off to let out the evil spirits that gave her cancer", then maybe the problem is actually unrelated to jackhammers[/quote]

Share this post


Link to post
Share on other sites

AutoIts ping will not resolve address to IP or IP to address. Maybe a feature request but I'll not be the one to ask for it. :)

If you want to resolve IP address to name then this will work.

$In = "209.85.173.99"

$Out = ""

$Var = Run (@Comspec & " /c ping -a " & $In, "", @SW_Hide, 2)

While Not @Error

$Out &= StdoutRead ($Var)

Wend

MsgBox(0,"Test", $Out)


George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

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