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 

checking internet connection

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





PostPosted: Fri Jul 23, 2004 3:22 pm    Post subject: checking internet connection Reply with quote

Hi
Thank you for this great prog. I want to run a script which checks my internet connection say every 15 mins. If im not connected it reboots.
Code:

Loop
{
FileDelete, C:\WINDOWS\Temporary Internet Files\google.htm
sleep, 2000
FileDelete, C:\google.htm
sleep, 2000
URLDownloadToFile, http://www.google.com, C:\google.htm
sleep, 2000
IfExist, C:\google.htm
{
sleep, 900000 ;15 mins
}
Else
{
Shutdown, 6 ;reboot
}
}
return

but this line
Code:
FileDelete, C:\WINDOWS\Temporary Internet Files\google.htm
is not deleting the file.
Any ideas?
Thanks
Back to top
BoBo
Guest





PostPosted: Fri Jul 23, 2004 5:27 pm    Post subject: Reply with quote

A workaround ...

tempfile = C:\WINDOWS\Temporary Internet Files\google.htm
Run, %comspec% /c del "%tempfile%",, Hide

(I have some issues with FileMove Confused)
Back to top
Chris
Site Admin


Joined: 02 Mar 2004
Posts: 10467

PostPosted: Fri Jul 23, 2004 5:29 pm    Post subject: Reply with quote

You probably shouldn't delete files directly from the cache. Maybe the delete fails because the OS won't let you.

But the most important thing is that there is a much easier way to check your connection: Use the built-in variables A_IPAddress1 through 4. One of them (probably the 1st or 2nd) should be different (perhaps 0.0.0.0) when you are not connected. This assumes you're using dial-up or a DHCP IP address rather than a hard-coded one.
Back to top
View user's profile Send private message Send e-mail
al
Guest





PostPosted: Sat Jul 24, 2004 1:27 am    Post subject: Reply with quote

thanks for reply guys.
This one works
Code:

x=%A_IPAddress1%
sleep, 2000
Loop
{
IfEqual, x, %A_IPAddress1%
{
sleep, 900000
}
Else
{
Shutdown, 6 ;reboot
}
}
return
Back to top
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