AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

ping

 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help
View previous topic :: View next topic  
Author Message
Candle



Joined: 19 Aug 2004
Posts: 334

PostPosted: Fri Aug 20, 2004 9:08 am    Post subject: ping Reply with quote

Is there a ping command ? Like to make a app that will ping a url and give a massage if it goes down .
Back to top
View user's profile Send private message
Chris
Site Admin


Joined: 02 Mar 2004
Posts: 10464

PostPosted: Fri Aug 20, 2004 1:00 pm    Post subject: Reply with quote

It's on the to-do list. In the meantime, you can ping using Windows such as in this example:

RunWait, %comspec% /c ping -n 2 www.yahoo.com | find "Minimum =" >PingOutput.txt, , hide
FileReadLine, line, PingOutput.txt, 1
MsgBox %line%
Back to top
View user's profile Send private message Send e-mail
Candle



Joined: 19 Aug 2004
Posts: 334

PostPosted: Fri Aug 20, 2004 10:04 pm    Post subject: Reply with quote

I will try that Chris . can I do the same thing with it like I did the script
that lets you add your email address to a window with the input box?
That way I don't have to hard code it in to use .
Back to top
View user's profile Send private message
Candle



Joined: 19 Aug 2004
Posts: 334

PostPosted: Fri Aug 20, 2004 10:12 pm    Post subject: Reply with quote

Never main Chris I got it to work with this .
Quote:
InputBox, OutputVar, Enter the ip number.
MsgBox You entered %OutputVar%.
RunWait, %comspec% /c ping -n 2 %OutputVar%| find "Minimum =" >PingOutput.txt, , hide
FileReadLine, line, PingOutput.txt, 1
MsgBox %line%
Back to top
View user's profile Send private message
Candle



Joined: 19 Aug 2004
Posts: 334

PostPosted: Fri Aug 20, 2004 10:46 pm    Post subject: Reply with quote

How can I make it quit if they click cancel ?
Quote:
InputBox, OutputVar, Enter the ip number.
if ErrorLevel <> 0
MsgBox, CANCEL was pressed.
else
MsgBox, You entered "%OutputVar%"
RunWait, %comspec% /c ping -n 2 %OutputVar%| find "Minimum =" >PingOutput.txt, , hide
FileReadLine, line, PingOutput.txt, 1
MsgBox %line%

I tried Exit ; Terminate this subroutine as well as the calling subroutine.
right after MsgBox, CANCEL was pressed. but gave me an error , not sure where to put it .
Back to top
View user's profile Send private message
BoBo
Guest





PostPosted: Fri Aug 20, 2004 11:00 pm    Post subject: Reply with quote

Check AHK's help for this keyword: IfMsgBox
Back to top
Candle



Joined: 19 Aug 2004
Posts: 334

PostPosted: Fri Aug 20, 2004 11:03 pm    Post subject: Reply with quote

Saw that bobo but not sure where to put it in the code ?
Back to top
View user's profile Send private message
BoBo
Guest





PostPosted: Fri Aug 20, 2004 11:07 pm    Post subject: Reply with quote

InputBox, OutputVar, Enter the ip number.

IfMsgBox, CANCEL
MsgBox, CANCEL was pressed.
else
MsgBox, You entered "%OutputVar%"

RunWait, %comspec% /c ping -n 2 %OutputVar%| find "Minimum =" >PingOutput.txt, , hide
FileReadLine, line, PingOutput.txt, 1
MsgBox %line%
Back to top
Candle



Joined: 19 Aug 2004
Posts: 334

PostPosted: Fri Aug 20, 2004 11:09 pm    Post subject: Reply with quote

Heh heh , I just did this and it worked but I lost my txt up on the top say Enter IP number .
Quote:
InputBox, OutputVar, Enter the ip number.
if ErrorLevel <> 0
MsgBox, CANCEL was pressed.
else
MsgBox, You entered "%OutputVar%"
if ErrorLevel <>0
Exit ; Terminate this subroutine as well as the calling subroutine.
RunWait, %comspec% /c ping -n 2 %OutputVar%| find "Minimum =" >PingOutput.txt, , hide
FileReadLine, line, PingOutput.txt, 1
MsgBox %line%

Now I will try yours . Smile
Back to top
View user's profile Send private message
BoBo
Guest





PostPosted: Fri Aug 20, 2004 11:10 pm    Post subject: Reply with quote

Ooops, to quit:

Code:
IfMsgBox, CANCEL
     ExitApp
else
     MsgBox, You entered "%OutputVar%"
Back to top
Candle



Joined: 19 Aug 2004
Posts: 334

PostPosted: Fri Aug 20, 2004 11:12 pm    Post subject: Reply with quote

Thanks for the help bobo .
Back to top
View user's profile Send private message
Chris
Site Admin


Joined: 02 Mar 2004
Posts: 10464

PostPosted: Fri Aug 20, 2004 11:48 pm    Post subject: Reply with quote

The IfMsgBox command doesn't relate to the InputBox command. Instead, "If the user presses the CANCEL button: ErrorLevel is set to 1 and OutputVar to the value entered." (quoted from the help file)

The revised script below illustrates the difference between how the buttons are handled with InputBox and MessageBox:
Code:
InputBox, OutputVar, Enter the host name (e.g. www.yahoo.com) or IP address
if ErrorLevel <> 0  ; Cancel was pressed.
     ExitApp
; Otherwise, continue on:
MsgBox, 4, , You entered "%OutputVar%"  Do you wish to ping it?
IfMsgBox, NO, ExitApp
; Otherwise, continue on:
RunWait, %comspec% /c ping -n 2 %OutputVar%| find "Minimum =" >PingOutput.txt, , hide
FileReadLine, line, PingOutput.txt, 1
MsgBox %line%
Back to top
View user's profile Send private message Send e-mail
Candle



Joined: 19 Aug 2004
Posts: 334

PostPosted: Fri Aug 20, 2004 11:51 pm    Post subject: Reply with quote

Thanks Chris . that work for me too. all new to me here but I think I'm learning this better then autoit .
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group