 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
Candle
Joined: 19 Aug 2004 Posts: 334
|
Posted: Fri Aug 20, 2004 9:08 am Post subject: ping |
|
|
| 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 |
|
 |
Chris Site Admin
Joined: 02 Mar 2004 Posts: 10464
|
Posted: Fri Aug 20, 2004 1:00 pm Post subject: |
|
|
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 |
|
 |
Candle
Joined: 19 Aug 2004 Posts: 334
|
Posted: Fri Aug 20, 2004 10:04 pm Post subject: |
|
|
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 |
|
 |
Candle
Joined: 19 Aug 2004 Posts: 334
|
Posted: Fri Aug 20, 2004 10:12 pm Post subject: |
|
|
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 |
|
 |
Candle
Joined: 19 Aug 2004 Posts: 334
|
Posted: Fri Aug 20, 2004 10:46 pm Post subject: |
|
|
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 |
|
 |
BoBo Guest
|
Posted: Fri Aug 20, 2004 11:00 pm Post subject: |
|
|
| Check AHK's help for this keyword: IfMsgBox |
|
| Back to top |
|
 |
Candle
Joined: 19 Aug 2004 Posts: 334
|
Posted: Fri Aug 20, 2004 11:03 pm Post subject: |
|
|
| Saw that bobo but not sure where to put it in the code ? |
|
| Back to top |
|
 |
BoBo Guest
|
Posted: Fri Aug 20, 2004 11:07 pm Post subject: |
|
|
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
|
Posted: Fri Aug 20, 2004 11:09 pm Post subject: |
|
|
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 .  |
|
| Back to top |
|
 |
BoBo Guest
|
Posted: Fri Aug 20, 2004 11:10 pm Post subject: |
|
|
Ooops, to quit:
| Code: | IfMsgBox, CANCEL
ExitApp
else
MsgBox, You entered "%OutputVar%" |
|
|
| Back to top |
|
 |
Candle
Joined: 19 Aug 2004 Posts: 334
|
Posted: Fri Aug 20, 2004 11:12 pm Post subject: |
|
|
| Thanks for the help bobo . |
|
| Back to top |
|
 |
Chris Site Admin
Joined: 02 Mar 2004 Posts: 10464
|
Posted: Fri Aug 20, 2004 11:48 pm Post subject: |
|
|
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 |
|
 |
Candle
Joined: 19 Aug 2004 Posts: 334
|
Posted: Fri Aug 20, 2004 11:51 pm Post subject: |
|
|
| 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 |
|
 |
|
|
You can post new topics in this forum You can reply to topics in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|