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 

Severe Weather Alert

 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions
View previous topic :: View next topic  
Author Message
Slanter



Joined: 28 May 2008
Posts: 259
Location: Minnesota, USA

PostPosted: Wed May 28, 2008 2:17 am    Post subject: Severe Weather Alert Reply with quote

This script will pop a little tray tip when it finds severe weather in your area. To use, change the Zone variable to your state/zone, save and run.

Your "Zone":
Found by going to http://www.weather.gov/alerts/ and
1. Find your state on the list, click on the RSS button in the third column
2. Find your county.
3. The ending of that url is your zone (ie http://www.weather.gov/alerts/wwarssget.php?zone=MNZ070 would be MNZ070)

Code:
#Persistent
HKey = F12
Zone = MNZ070

Hotkey, %HKey%, OpenLink
Update:
   SetTimer, Update, off
   UrlDownloadToFile, http://www.weather.gov/alerts/wwarssget.php?zone=%Zone%, WxDat.txt
   If (ErrorLevel)
   {
      TrayTip, WxAlert Error, WxAlert was unable to download the most recent weather data from weather.gov.`nTrying again in 5 minutes., 10
      SetTimer, Update, 300000
      Return
   }
   INum     := 0
   OpenItem := 0
   Loop, Read, WxDat.txt
   {
      If (RegExMatch(A_LoopReadLine, "^\s*\</item\>\s*$"))
         OpenItem := 0
      If (OpenItem)
      {
         IVar := (ILine == 0 ? "ITitle" : ILine == 1 ? "ILink" : "IDesc") . INum
         %IVar% := (%IVar% != "" ? %IVar% . "`n" : "") . RegExReplace(A_LoopReadLine,"\<[^>]*>")
         ILine++
      }
      If (RegExMatch(A_LoopReadLine, "^\s*\<item\>\s*$"))
      {
         OpenItem := 1
         ILine    := 0
         INum++
      }
   }
   Loop, % INum
   {
      CheckWxDat(ITitle%A_Index%,ILink%A_Index%,IDesc%A_Index%)
      ITitle%A_Index% =
      ILink%A_Index% =
      IDesc%A_Index% =
   }
   SetTimer, Update, 300000
Return

OpenLink:
   If (WebLink)
      Run, %WebLink%
Return

CheckWxDat(Title,Link,Desc)
{
   Global HKey,WebLink
   Link := RegExReplace(Link,"\s")
   WebLink := Link
   If (!RegExMatch(Title,"^\s*(Severe )?(.*) (Watch|Warning) - .*$",WData))
      Return
   Sever := WData1
   WType := WData2
   SType := WData3
   WTime = ????
   Loop, Parse, Desc, `n
   {
      If (RegExMatch(A_LoopField, "UNTIL ([0-9]{3,4}) ?(AM|PM)", WDat))
         WTime := RegExReplace(WDat1,"([0-9]{2})$",":$1") . WDat2
   }
   WStr = There is a %Sever%%WType% %SType% in effect in your area until %WTime%
   TrayTip, %Sever%%WType% %SType%, %WStr%`n`nPlease press go to the following website for more information`n(or press %HKey% to open the link in your web browser):`n%Link%, 10
   Sleep, 10000
   WebLink =
}


Screenshot:


Last edited by Slanter on Thu Jun 05, 2008 7:13 pm; edited 3 times in total
Back to top
View user's profile Send private message Visit poster's website
Rhys



Joined: 17 Apr 2007
Posts: 722
Location: Florida

PostPosted: Wed May 28, 2008 3:43 am    Post subject: Reply with quote

This is a very cool idea for a script - I have a suggestion based on the screenshot - I don't think there's a way to copy text from a traytip, and that URL isn't 'easy' to type - Perhaps find a way to open that page if the bubble is clicked, or use an alternate notification that can do the same (like a toaster popup)?

If you felt like it you could modify the toaster popup function to add a cute little icon of whatever sever weather you were getting (hail, thunder, etc.)...

Thanks for sharing!
_________________
[Join IRC!]
Back to top
View user's profile Send private message
Slanter



Joined: 28 May 2008
Posts: 259
Location: Minnesota, USA

PostPosted: Wed May 28, 2008 4:18 am    Post subject: Reply with quote

Thanks for the feedback Very Happy

Just to keep it simple I made a hotkey that will just run the link, and made the traytip title say the type of severe weather
Back to top
View user's profile Send private message Visit poster's website
Rhys



Joined: 17 Apr 2007
Posts: 722
Location: Florida

PostPosted: Wed May 28, 2008 5:22 am    Post subject: Reply with quote

Cool, nice idea about the hotkey - Simpler is often better Cool
_________________
[Join IRC!]
Back to top
View user's profile Send private message
SoggyDog



Joined: 02 May 2006
Posts: 214
Location: Greeley, CO

PostPosted: Wed May 28, 2008 6:37 pm    Post subject: Reply with quote

Nice! Coulda used this last week in Colorado!
_________________

SoggyDog
Download AutoHotKey Wallpaper
Does 'Fuzzy Logic' tickle?
Back to top
View user's profile Send private message Send e-mail Visit poster's website MSN Messenger
SoggyDog



Joined: 02 May 2006
Posts: 214
Location: Greeley, CO

PostPosted: Wed Jun 04, 2008 10:14 pm    Post subject: Reply with quote

I ran this today because we have some bad weather (made sure I set the right zone) and I wasn't getting any notices; I checked my system tray and there was no icon for it; Then I checked my Applications and my Processes and didn't see it running under either. I tried running it again and noticed right away that it didn't start up... Just dies. I even tried compiling it. Have I done something wrong?
_________________

SoggyDog
Download AutoHotKey Wallpaper
Does 'Fuzzy Logic' tickle?
Back to top
View user's profile Send private message Send e-mail Visit poster's website MSN Messenger
Slanter



Joined: 28 May 2008
Posts: 259
Location: Minnesota, USA

PostPosted: Thu Jun 05, 2008 2:43 am    Post subject: Reply with quote

I just turned mine on and it seems to work fine... can you post your code?
Back to top
View user's profile Send private message Visit poster's website
SoggyDog



Joined: 02 May 2006
Posts: 214
Location: Greeley, CO

PostPosted: Thu Jun 05, 2008 4:58 am    Post subject: Reply with quote

Copy/Pasted straight from top post;
Changed code to COZ043.
_________________

SoggyDog
Download AutoHotKey Wallpaper
Does 'Fuzzy Logic' tickle?
Back to top
View user's profile Send private message Send e-mail Visit poster's website MSN Messenger
Slanter



Joined: 28 May 2008
Posts: 259
Location: Minnesota, USA

PostPosted: Thu Jun 05, 2008 6:21 am    Post subject: Reply with quote

mine still works fine with that zone Confused
Back to top
View user's profile Send private message Visit poster's website
SoggyDog



Joined: 02 May 2006
Posts: 214
Location: Greeley, CO

PostPosted: Thu Jun 05, 2008 2:13 pm    Post subject: Reply with quote

That's odd... And I've tried it on three (3) different XP sp2 machines. Are there any typos in the script that got posted? Anyone else having trouble getting this to run?
_________________

SoggyDog
Download AutoHotKey Wallpaper
Does 'Fuzzy Logic' tickle?
Back to top
View user's profile Send private message Send e-mail Visit poster's website MSN Messenger
Slanter



Joined: 28 May 2008
Posts: 259
Location: Minnesota, USA

PostPosted: Thu Jun 05, 2008 7:13 pm    Post subject: Reply with quote

I updated the code just in case, but it seemed to be the same
Back to top
View user's profile Send private message Visit poster's website
SoggyDog



Joined: 02 May 2006
Posts: 214
Location: Greeley, CO

PostPosted: Thu Jun 05, 2008 7:23 pm    Post subject: Reply with quote

I don't know why, but that did the trick.
It's alive!

Thanks a ton.
_________________

SoggyDog
Download AutoHotKey Wallpaper
Does 'Fuzzy Logic' tickle?
Back to top
View user's profile Send private message Send e-mail Visit poster's website MSN Messenger
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions 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