 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
TheWeatherGuy Guest
|
Posted: Mon Dec 22, 2008 2:01 am Post subject: Weather |
|
|
I am releasing my weather script for testing. It was created with lots of help from many people here - many thanks to Skwire, Titan, and k3ph by the way.
In the script, you have the option of using Location Detection. This allows you to view the weather relative to your current location. The script detects your current location using GeoIPTool.com. If you choose to not use Location Detection, you can enter in up to two custom locations. The update time is customizable and you can also set the script to display severe weather alerts on the Weather GUI.
Options GUI
The Weather GUI displays two forecasts. You can scroll with your mouse wheel to view additional forecasts (make sure that the Weather GUI is the active window). To toggle your location, middle click on the Weather GUI (this only works is Location Detection is unchecked in the Options GUI). If you have the script set up to display severe weather alerts and severe weather alerts exist for the displayed location, a red rounded rectangle with the word "Alert" will appear on the Weather GUI. To view the alerts, double click on the red rounded rectangle.
Weather GUI:
Alert GUI:
Right clicking on the Weather GUI makes a context menu appear. From here, you can change the options, view the Help GUI, manually update, lock/unlock the Weather GUI in place (you can drag the Weather GUI with the left mouse button is it is unlocked), and reload or exit the script.
Context Menu:
Help GUI:
The script is available in two flavors: an executable and an AHK script file. For the AHK script file, you need the GDI+ library to be in the same directory as the AHK script file.
The script creates up to three text documents, as it saves web pages as text files to use for information such as severe weather alerts and the weather forecast. In addition, a Settings.ini file is also created.
Here is the executable: http://www.autohotkey.net/~TheWeatherGuy/Weather/Weather.exe
Here is the AHK script: http://www.autohotkey.net/~TheWeatherGuy/Weather/Weather.ahk
Here is the link to the GDI+ Library (created by tic): http://www.autohotkey.com/forum/topic32238.html
Sometimes, the text forecast overextends its boundaries depending on the length of the text. I plan on updating the script with picture forecasts that display the text forecast in a tool tip when moused over. This will occur soon. I need to find the picture first.
I've tested the script on three computers: two were Vista SP1 OS's and one was an XP SP2 OS. They all handled the script fine. If you encounter any bugs, please post a detailed description of the problem (i.e. include what you were attempting to do, what occurred instead, if you were using the .exe or the .ahk, your OS, if you tried to reload the script, if you tried deleting all the files created by the .exe or .ahk and started the script fresh, ect.).
Please note that this script gets the weather forecast from the NWS (National Weather Service). Therefore, it will only work with U.S. cities and towns.
Happy Testing! |
|
| Back to top |
|
 |
Frankie
Joined: 02 Nov 2008 Posts: 2850
|
Posted: Mon Dec 22, 2008 2:30 am Post subject: |
|
|
Looks like a lot of work went into it. I got a lot of storms going on where I am so ill be sure to use this. Thanks for the script! _________________ aboutscript ⍟ apps ⍟ scripts
Any code ⇈ above ⇈ requires AutoHotkey_L to run |
|
| Back to top |
|
 |
TheWeatherGuy Guest
|
Posted: Mon Dec 22, 2008 2:43 am Post subject: |
|
|
| You are very welcome! I spent about two months coding this thing (I'm not sure if that's considered long or not). I hope you enjoy it. Just remember though, it only works with U.S. locations. |
|
| Back to top |
|
 |
Frankie
Joined: 02 Nov 2008 Posts: 2850
|
Posted: Mon Dec 22, 2008 2:45 am Post subject: |
|
|
Thats a very long time for an AHK program. _________________ aboutscript ⍟ apps ⍟ scripts
Any code ⇈ above ⇈ requires AutoHotkey_L to run |
|
| Back to top |
|
 |
SoggyDog
Joined: 02 May 2006 Posts: 783 Location: Greeley, CO
|
|
| Back to top |
|
 |
SoggyDog
Joined: 02 May 2006 Posts: 783 Location: Greeley, CO
|
Posted: Mon Dec 22, 2008 6:46 pm Post subject: |
|
|
I added a 'Search' feature (code by Klaus) to the Weather Alerts GUI;
This makes it easier to find out if your County/Region is included in the Alert.
[Edit]
Bug Fix: Search feature now functions properly when there are multiple Alerts (tabs).
| Code: | ;TheWeatherGuy Weather 1.8 December 21, 2008
;Search feature added by Soggy Dog [December 22, 2008]
;Search code by Klaus [http://www.autohotkey.com/forum/viewtopic.php?t=39120]
;Things to Do:
;Add pictures with tooltip forecast (FileInstall)
;Change Icon
;------------------------------------------------------------------------------------------------------------------------
#SingleInstance force
#NoTrayIcon
#Include, Gdip.ahk
;------------------------------------------------------------------------------------------------------------------------
Set_ScriptVariables()
IfNotExist, Settings.ini
{
Set_DefaultVariables()
Display_Welcome()
Load_WeatherContextMenu()
Gosub, Display_Options
}else
{
Load_WeatherContextMenu()
Gosub, Update_Weather
}
RETURN
;------------------------------------------------------------------------------------------------------------------------
2ButtonOK:
Gui, 2: Submit
Menu, WeatherMenu, Enable, Options...
IfNotExist, Settings.ini
UseLocation:=Location1
else
{
IfEqual, LocationA, %UseLocation%
UseLocation:=Location1
else
UseLocation:=Location2
}
Save_UserSettings()
return
2GuiClose:
IfNotExist, Settings.ini
ExitApp
Menu, WeatherMenu, Enable, Options...
Gui, 2: Destroy
return
3GuiClose:
Gui, 3: Destroy
return
3GuiSize:
WinGetPos,,, AlertW, AlertH, Alert Information
Loop, %Length%
GuiControl, 3: Move, AlertBox%a_index%, % "w" (AlertW-60) "h" (AlertH-100)
return
4GuiClose:
Gui, 4: Destroy
return
Alert_Alert:
URLDownloadToFile, %AlertBaseURL%%Alert1%, Rough_Alert.txt
FileRead, RoughAlert, Rough_Alert.txt
grep(RoughAlert, "<h3>([^<]*?)</h3>", RoughSevereA)
StringSplit, RoughSevereB, RoughSevereA, `,
Length:=0
Loop, parse, RoughSevereA, `,
Length+=1
Loop, %Length%
{
S:=RoughSevereB%a_index%
RegExMatch(S, "<h3>([^<]*?)</h3>", RoughSevereC)
IfEqual, a_index, 1
Severe := RoughSevereC1
else
Severe := Severe "|" RoughSevereC1
}
grep(RoughAlert, "s)<pre>(.+)<\/pre>", RoughSevereDescr)
StringReplace, RoughSevereDescrA, RoughSevereDescr,</pre>, ``, All
StringSplit, RoughSevereDescrB, RoughSevereDescrA, ``
Loop, %Length%
{
S:=RoughSevereDescrB%a_index%
RegExMatch(S, "s)<pre>(.+)\$\$", RoughSevereDescrC)
SevereDescr%a_index% := RoughSevereDescrC1
}
Gui, 3: Add, Tab2, vTabbedAlerts w%AlertTabWidth% h%AlertTabHeight% +Buttons TCS_FLATBUTTONS , %Severe%
brush := DllCall("CreateSolidBrush", "UInt", RGB(255,255,255))
OnMessage(0x138, "Change_BackgroundColor")
Loop, %Length%
{
Gui, 3: Tab, %a_index%
AlertDescr:=SevereDescr%a_index%
Gui, 3: Add, Edit, ReadOnly vAlertBox%a_index% +VScroll HwndAlertID%a_index%, %AlertDescr%
}
width := RegExReplace(AlertTabWidth, "\.\d*")
Search_Button_Location := width-75
Search_Field_Location := width-180
SB_Part_Width := width-90
Gui, 3: +Resize +MinSize
Gui, 3: Tab
Gui, 3: Add, Button, x%Search_Button_Location% y7 gFindString default, Search
Gui, 3: Add, Edit, x%Search_Field_Location% y8 w100 vfind
Gui, 3: Add, StatusBar,, Enter County, Region or keyword to search for, then click ''Search''.
Gui, 3: Show, w%AlertTabWidth% h%AlertTabHeight%, Alert Information
Gui, 3: Default
SB_SetParts(SB_Part_Width)
SelectText(AlertID1, -1, -1)
WinGet ControlID, ID, Alert Information
return
Change_BackgroundColor(wParam, lParam, msg, hwnd)
{
global
If(A_Gui = 3 or A_Gui = 4)
{
DllCall("SetTextColor", "UInt", wParam, "UInt", RGB(0, 0, 0))
DllCall("SetBkMode", "UInt", wParam, "UInt", 1)
Return brush
}
}
CurrentOne:
GuiControl, Text, Location1, %CurrentLocation%
return
CurrentTwo:
GuiControl, Text, Location2, %CurrentLocation%
return
Display_Help:
IfWinNotExist, %ProgramName% Help
{
HelpTopic1=Right click on the Weather GUI and select "Options...".
HelpTopic2=Right click on the Weather GuI and select "Lock" to lock the Weather GUI. To unlock the Weather GUI, repeat the action.
HelpTopic3=Right click on the Weather GUI and select "Update".
HelpTopic4=Hold down the left mouse button on the Weather GUI and move the mouse.
HelpTopic5=Right click on the Weather GUI and select "Exit".
HelpTopic6=Right click on the Weather GUI and select "Reload".
HelpTopic7=Middle click on the Weather GUI (only works if Location Detection is unchecked in Options).
HelpTopic8=Scroll the mouse wheel on the Weather GUI (the Weather GUI must be the active window for this to work, so click on the Weather GUI if the scrolling does not work).
HelpTopic9=Ensure that "Display Severe Weather Alerts" in Options is checked. When there is an severe weather alert, a red rounded rectangle will appear on the Weather GUI. Double click that red rounded rectangle with the left mouse button to view the details of the severe weather alert(s).
HelpTopic10=Ensure that "Use Location Detection" in Options is checked.
HelpTopic11=Enter your search string and click ''Search''.
Gui, 4: Add, Text,, I want to...
HelpList=Edit the Options||Lock/Unlock the Weather GUI|Manually Update the Forecast|Move the Weather GUI|Quit %ProgramName%|Restart %ProgramName%|Toggle Forecasted Location|View More of the Forecast|View Severe Weather Alerts|View the Forecast of My Current Location|Search for my County / Region
Gui, 4: Add, ListBox, Section w%HelpWidth% h%HelpHeight% vHelpTopics gDisplay_HelpInformation AltSubmit, %HelpList%
brush := DllCall("CreateSolidBrush", "UInt", RGB(255,255,255))
OnMessage(0x138, "Change_BackgroundColor")
Gui, 4: Add, Edit, % "w" . HelpWidth-30 . " h" . HelpHeight-4 . " ys ReadOnly vHelpInfo +VScroll +Wrap HwndInfoID"
Gui, 4: Show, AutoSize, %ProgramName% Help
GuiControl, 4: +Redraw, HelpInfo
Gosub, Display_HelpInformation
}
return
Display_HelpInformation:
Gui, 4: Submit, NoHide
ShowTheInfo:= HelpTopic%HelpTopics%
GuiControl, 4: Text, HelpInfo, %ShowTheInfo%
return
Display_Options:
Menu, WeatherMenu, Disable, Options...
Get_Location()
Gui, 2: Add, Text, Section w240 h22 Center vTitleA, Current Location Detected As:
Gui, 2: Add, Text, ys+17 xs w240 h22 Center vTitleB, %CurrentLocation%
Gui, 2: Add, Text, Section, Enter Location One:
Gui, 2: Add, Edit, w120 h22 -Multi vLocation1, %LocationA%
Gui, 2: Add, Button, vUseItA gCurrentOne, Use Current Location
Gui, 2: Add, Text, ys vTextLoc2, Enter Location Two:
Gui, 2: Add, Edit, w120 h22 -Multi vLocation2, %LocationB%
Gui, 2: Add, Button, vUseItB gCurrentTwo, Use Current Location
Gui, 2: Add, Text, xs y+30, Select Update Frequency (minutes):
Gui, 2: Add, Edit, xs
Gui, 2: Add, UpDown, vUpdateFrequency Range1-180, %UpdateFrequency%
Gui, 2: Add, Checkbox, Checked%LocationDetectionState% vLocationDetection gToggle_LocationControls, Use Location Detection
Gui, 2: Add, Checkbox, Checked%ShowAlertState% vShowAlerts, Display Severe Weather Alerts
Gui, 2: Add, Button, y+10 default, OK
Gui, 2: Show, AutoSize Center, %ProgramName% Options
WinGetPos,,, WeatherWidthConfig,, %ProgramName% Options
MoveXA := WeatherWidthConfig/2, MoveXB := MoveXA/2
GuiControl, 2: MoveDraw, OK, x%MoveXB% W%MoveXA%
Gosub, Toggle_LocationControls
return
Display_Weather:
SetBatchLines, -1
If !pToken := Gdip_Startup()
{
MsgBox, 48, gdiplus error!, Gdiplus failed to start. Please ensure you have gdiplus on your system
ExitApp
}OnExit, Exit
Gui, 1: -Caption +E0x80000 +LastFound +ToolWindow +OwnDialogs
Gui, 1: Show, NoActivate, Weather GUI
IfEqual, TimerUsed, 1
{
WinSet, Bottom,, Weather GUI
TimerUsed:=0
}
hwnd1 := WinExist()
hbm := CreateDIBSection(WeatherWidth, WeatherHeight)
hdc := CreateCompatibleDC()
obm := SelectObject(hdc, hbm)
G := Gdip_GraphicsFromHDC(hdc)
Gdip_SetSmoothingMode(G, 4)
pBrush := Gdip_BrushCreateSolid(0xaa000000)
Gdip_FillRoundedRectangle(G, pBrush, 0, 0, WeatherWidth, WeatherHeight, 20)
Gdip_DeleteBrush(pBrush)
If !Gdip_FontFamilyCreate(Font)
{
MsgBox, 48, Font error!, The font you have specified does not exist on the system
ExitApp
}
IfEqual, Warning, 1
{
pBrush := Gdip_BrushCreateSolid(0xcf800000)
Gdip_FillRoundedRectangle(G, pBrush, WarningX, WarningY, 90, 30, 5)
Gdip_DeleteBrush(pBrush)
Options1 = x5p y88p w90p Bold Centre cbbffffff r4 s16
Gdip_TextToGraphics(G, "ALERT", Options1, Font, WeatherWidth, WeatherHeight)
}
Options2 = x5p y1p w90p Underline Bold Centre cbbffffff r4 s14
Options3 = x5p y10p w90p Underline Bold Centre cbbffffff r4 s12
Options4 = x5p y15p w90p Centre cbbffffff r4 s12
Options5 = x5p y45p w90p Underline Bold Centre cbbffffff r4 s12
Options6 = x5p y50p w90p Centre cbbffffff r4 s12
Options7 = x5p y96p w90p Centre cbbffffff r4 s10
Options8 = x3p y93p w90p Right cbbffffff r4 s10
IfEqual, LocationDetectionState, 1
Gdip_TextToGraphics(G, CurrentLocation, Options2, Font, WeatherWidth, WeatherHeight)
else
Gdip_TextToGraphics(G, UseLocation, Options2, Font, WeatherWidth, WeatherHeight)
Set_Forecast()
Gdip_TextToGraphics(G, ForecastTitle1, Options3, Font, WeatherWidth, WeatherHeight)
Gdip_TextToGraphics(G, ForecastDescr1, Options4, Font, WeatherWidth, WeatherHeight)
Gdip_TextToGraphics(G, ForecastTitle2, Options5, Font, WeatherWidth, WeatherHeight)
Gdip_TextToGraphics(G, ForecastDescr2, Options6, Font, WeatherWidth, WeatherHeight)
Gdip_TextToGraphics(G, LastUpdate, Options7, Font, WeatherWidth, WeatherHeight)
Page:=Round(ForecastD/4) " of 6"
Gdip_TextToGraphics(G, Page, Options8, Font, WeatherWidth, WeatherHeight)
UpdateLayeredWindow(hwnd1, hdc, WeatherX, WeatherY, WeatherWidth, WeatherHeight)
OnMessage(0x20A, "WM_MOUSEWHEEL")
OnMessage(0x207, "WM_MBUTTONDOWN")
OnMessage(0x218, "WM_POWERBROADCAST")
OnMessage(0x204, "WM_RBUTTONDOWN")
OnMessage(0x203, "WM_LBUTTONDBLCLK")
OnMessage(0x201, "WM_LBUTTONDOWN")
SelectObject(hdc, obm)
DeleteObject(hbm)
DeleteDC(hdc)
RETURN
return
Display_Welcome()
{
global
MsgBox, 33, Welcome to %ProgramName%, Welcome to %ProgramName%!`n`nWould you like to begin Setup?
IfMsgBox Cancel
ExitApp
}
Exit:
Gdip_Shutdown(pToken)
ExitApp
return
Get_Location()
{
global
UrlDownloadToFile, %LocationURL%, Rough_CurrentLocation.txt
FileRead, RoughLocation, Rough_CurrentLocation.txt
RegExMatch(RoughLocation, ">City:<.+?\barial_bold"">([^>]*?)</td>", city)
RegExMatch(RoughLocation, "target=""_blank"">([^>]*?)</a></td>", state)
CurrentLocation:=city1 ", " state1
}
Get_Weather:
Load_UserSettings()
IfEqual, LocationDetectionState, 1
{
Get_Location()
URLDownloadToFile, %WeatherBaseURL%%CurrentLocation%, Rough_Weather.txt
}else
URLDownloadToFile, %WeatherBaseURL%%UseLocation%, Rough_Weather.txt
FileRead, RoughWeather, Rough_Weather.txt
RegExMatch(RoughWeather, "name=""contents""></a>\s*<b>([^<]*?)</b>([^<]*?)<br><br><b>([^<]*?)</b>([^<]*?)<br><br><b>([^<]*?)</b>([^<]*?)<br><br><b>([^<]*?)</b>([^<]*?)<br><br><b>([^<]*?)</b>([^<]*?)<br><br><b>([^<]*?)</b>([^<]*?)<br><br><b>([^<]*?)</b>([^<]*?)<br><br><b>([^<]*?)</b>([^<]*?)<br><br><b>([^<]*?)</b>([^<]*?)<br><br><b>([^<]*?)</b>([^<]*?)<br><br><b>([^<]*?)</b>([^<]*?)<br><br><b>([^<]*?)</b>([^<]*?)<br><br><b>([^<]*?)</b>([^<]*?)<br>", descr)
IfEqual, descr1,
{
RegExMatch(RoughWeather, "name=""contents""></a>\s*Hazardous weather condition\(s\):<br><div align=""center""><br><a href=(.*)</span></a><br></div><br>\s*<b>([^<]*?)</b>([^<]*?)<br><br><b>([^<]*?)</b>([^<]*?)<br><br><b>([^<]*?)</b>([^<]*?)<br><br><b>([^<]*?)</b>([^<]*?)<br><br><b>([^<]*?)</b>([^<]*?)<br><br><b>([^<]*?)</b>([^<]*?)<br><br><b>([^<]*?)</b>([^<]*?)<br><br><b>([^<]*?)</b>([^<]*?)<br><br><b>([^<]*?)</b>([^<]*?)<br><br><b>([^<]*?)</b>([^<]*?)<br><br><b>([^<]*?)</b>([^<]*?)<br><br><b>([^<]*?)</b>([^<]*?)<br><br><b>([^<]*?)</b>([^<]*?)<br>", descr)
RegExMatch(descr1, """([^<]*?)"">", Alert)
IfEqual, ShowAlertState, 1
{
Warning:=1
ClickIt:=1
}
loop, 26
{
next:=a_index+1
descr%a_index%:=descr%next%
}
}else
{
ClickIt:=0
Warning:=0
}
FormatTime, LastUpdateBase,, h:mm tt MMM dd, yyyy
LastUpdate:="Last Update: "LastUpdateBase
UpdateMilliTime := UpdateFrequency*60000
SetTimer, Update_WeatherTimer, %UpdateMilliTime%
return
grep(h, n, ByRef v, b = 0, s = 1, d = ",", z = true)
{
Loop
If s := RegExMatch(h, n, c, s)
p .= s . d, s += z ? StrLen(c) : 1, y .= (b ? c%b% : c) . d
Else Return, SubStr(p, 1, -1), v := SubStr(y, 1, -1)
}
Load_WeatherContextMenu()
{
global
Menu, WeatherMenu, Add, Options..., Display_Options
Menu, WeatherMenu, Add, Help..., Display_Help
Menu, WeatherMenu, Add, Update, Update_Weather
Menu, WeatherMenu, Add, Lock, LockIt
Menu, WeatherMenu, Add, Reload, Restart
Menu, WeatherMenu, Add, Exit, Exit
}
Load_UserSettings()
{
global
IniRead, LocationA, Settings.ini, Locations, Location One
IniRead, LocationB, Settings.ini, Locations, Location Two
IniRead, UseLocation, Settings.ini, Locations, Use Location
IniRead, ForecastA, Settings.ini, Forecast, ForecastTitle1
IniRead, ForecastB, Settings.ini, Forecast, ForecastDescr1
IniRead, ForecastC, Settings.ini, Forecast, ForecastTitle2
IniRead, ForecastD, Settings.ini, Forecast, ForecastDescr2
IniRead, UpdateFrequency, Settings.ini, Update, Frequency
IniRead, LocationDetectionState, Settings.ini, Detection, Locatation Detection
IniRead, Ref1, Settings.ini, Detection, Reference Location One
IniRead, Ref2, Settings.ini, Detection, Reference Location Two
IniRead, ShowAlertState, Settings.ini, Alert, Show Alerts
IniRead, WeatherX, Settings.ini, GUI Location, WindowX
IniRead, WeatherY, Settings.ini, GUI Location, WindowY
IniRead, Lock, Settings.ini, GUI Location, Lock
IfEqual, Lock, 1
Menu, WeatherMenu, Check, Lock
IfEqual, ShowAlertState, 0
Warning:=0
}
LockIt:
IfEqual, Lock, 1
Lock := 0
else
Lock := 1
IniWrite, %Lock%, Settings.ini, GUI Location, Lock
Menu, WeatherMenu, ToggleCheck, Lock
Gosub, Display_Weather
return
RGB(r, g, b)
{
Return (b << 16) + (g << 8) + r
}
Restart:
Reload
return
Save_ForecastDays()
{
global
IniWrite, %ForecastA%, Settings.ini, Forecast, ForecastTitle1
IniWrite, %ForecastB%, Settings.ini, Forecast, ForecastDescr1
IniWrite, %ForecastC%, Settings.ini, Forecast, ForecastTitle2
IniWrite, %ForecastD%, Settings.ini, Forecast, ForecastDescr2
}
Save_Position()
{
global
WinGetPos, x, y,,, ahk_id %hwnd1%
WeatherX := x
WeatherY := y
IniWrite, %WeatherX%, Settings.ini, GUI Location, WindowX
IniWrite, %WeatherY%, Settings.ini, GUI Location, WindowY
}
Save_UserSettings()
{
global
IniWrite, %Location1%, Settings.ini, Locations, Location One
IniWrite, %Location2%, Settings.ini, Locations, Location Two
IniWrite, %UseLocation%, Settings.ini, Locations, Use Location
IniWrite, %ForecastA%, Settings.ini, Forecast, ForecastTitle1
IniWrite, %ForecastB%, Settings.ini, Forecast, ForecastDescr1
IniWrite, %ForecastC%, Settings.ini, Forecast, ForecastTitle2
IniWrite, %ForecastD%, Settings.ini, Forecast, ForecastDescr2
IniWrite, %UpdateFrequency%, Settings.ini, Update, Frequency
IniWrite, %LocationDetection%, Settings.ini, Detection, Locatation Detection
IniWrite, %ShowAlerts%, Settings.ini, Alert, Show Alerts
IniWrite, %WeatherX%, Settings.ini, GUI Location, WindowX
IniWrite, %WeatherY%, Settings.ini, GUI Location, WindowY
IniWrite, %Lock%, Settings.ini, GUI Location, Lock
Gui, 2: Destroy
Gosub, Update_Weather
}
Save_UseLocation()
{
global
IniWrite, %UseLocation%, Settings.ini, Locations, Use Location
Gosub, Update_Weather
}
SelectText( ControlID, start=0, end=-1 )
{
SendMessage, 0xB1, start, end,, ahk_id %ControlID%
return (ErrorLevel != "FAIL")
}
Set_DefaultVariables()
{
global
WeatherX := (A_ScreenWidth-WeatherWidth)/2, WeatherY := (A_ScreenHeight-WeatherHeight)/2
Lock := 0
UpdateFrequency = 60
LocationDetectionState = 0
ShowAlertState = 0
ForecastA := 1, ForecastB := 2, ForecastC := 3, ForecastD := 4
}
Set_Forecast()
{
global
ForecastTitle1:=descr%ForecastA%
ForecastDescr1:=descr%ForecastB%
ForecastTitle2:=descr%ForecastC%
ForecastDescr2:=descr%ForecastD%
}
Set_ScriptVariables()
{
global
ProgramName := "Weather"
WeatherBaseURL = http://forecast.weather.gov/zipcity.php?inputstring=
AlertBaseURL = http://forecast.weather.gov/
LocationURL = http://www.geoiptool.com
WeatherWidth := 195, WeatherHeight := 410
WarningX:=(WeatherWidth-90)/2, WarningY:=WeatherHeight-55
WarningXB:=WarningX+90, WarningYB:=WarningY+30
Font = Arial
AlertTabWidth:=A_ScreenWidth/2, AlertTabHeight:=A_ScreenHeight/3
HelpWidth:=A_ScreenWidth/7, HelpHeight:=A_ScreenHeight/6
}
Toggle_LocationControls:
GuiControlGet, OnOff, 2:, LocationDetection
IfEqual, OnOff, 1
{
GuiControl, 2: +ReadOnly, Location1
GuiControl, 2: +ReadOnly, Location2
GuiControl, 2: Disable, UseItA
GuiControl, 2: Disable, UseItB
}else
{
GuiControl, 2: -ReadOnly, Location1
GuiControl, 2: -ReadOnly, Location2
GuiControl, 2: Enable, UseItA
GuiControl, 2: Enable, UseItB
}
return
Update_Weather:
Gosub, Get_Weather
Gosub, Display_Weather
return
Update_WeatherTimer:
TimerUsed:=1
Gosub, Update_Weather
return
WM_LBUTTONDBLCLK()
{
global
IfWinNotExist, Alert Information
{
IfEqual, A_Gui, 1
{
IfEqual, ClickIt, 1
{
IfEqual, ShowAlertState, 1
{
CoordMode, Mouse, Relative
MouseGetPos, XClicked, YClicked
if XClicked between %WarningX% and %WarningXB%
{
if YClicked between %WarningY% and %WarningYB%
Gosub, Alert_Alert
RETURN
}
}
}
}
}
}
WM_LBUTTONDOWN()
{
global
If(A_Gui = 1 and Lock = 0)
{
PostMessage, 0xA1, 2
loop
{
GetKeyState, MouseUp, LButton, P
IfEqual, MouseUp, U
{
Save_Position()
BREAK
}
}
}
}
WM_MBUTTONDOWN()
{
global
IfEqual, A_Gui, 1
{
IfEqual, LocationDetectionState, 1
RETURN
else
{
loop
{
GetKeyState, MiddleUp, MButton, P
IfEqual, MiddleUp, U
{
IfEqual, UseLocation, %LocationA%
UseLocation:=LocationB
else
UseLocation:=LocationA
BREAK
}
}
Save_UseLocation()
}
}
}
WM_MOUSEWHEEL(wParam, lParam)
{
global
IfEqual, A_Gui, 1
{
If (wParam = 7864320)
{
IfEqual, ForecastD, 24
{
ForecastA:=1
ForecastB:=2
ForecastC:=3
ForecastD:=4
}else
{
ForecastA:=ForecastA+4
ForecastB:=ForecastB+4
ForecastC:=ForecastC+4
ForecastD:=ForecastD+4
}
Save_ForecastDays()
Gosub, Update_Weather
}
If (wParam = 4287102976)
{
IfEqual, ForecastA, 1
{
ForecastA:=21
ForecastB:=22
ForecastC:=23
ForecastD:=24
}else
{
ForecastA:=ForecastA-4
ForecastB:=ForecastB-4
ForecastC:=ForecastC-4
ForecastD:=ForecastD-4
}
Save_ForecastDays()
Gosub, Update_Weather
}
}
}
WM_POWERBROADCAST(wParam, lParam)
{
If (wParam = 7 OR wParam = 8)
SetTimer, Update_WeatherTimer, 30000
}
WM_RBUTTONDOWN()
{
IfEqual, A_Gui, 1
Menu, WeatherMenu, Show
}
;------------------------------------------------------------------------------------------------------------------------
FindString:
Gui 3:Submit, Nohide
controlGet, tabNumber, Tab, ,SysTabControl321
if (find != lastFind) {
offset = 0
hits = 0
}
Gui, 3: Tab, %tabNumber%
GuiControl 3:Focus, AlertBox%tabNumber%
SendMessage 0xB6, 0, -999, Edit%tabNumber%, ahk_id %ControlID%
StringGetPos pos, AlertBox%tabNumber%, %find% ,,offset
if (pos = -1) {
if (offset = 0) {
SB_SetText("'" . find . "' not found", 1)
SB_SetText("", 2)
}
else {
SB_SetText("No more occurrences of '" . find . "'")
SB_SetText("", 2)
offset = 0
hits = 0
}
return
}
StringLeft __s, AlertBox%tabNumber%, %pos%
StringReplace __s,__s,`n,`n,UseErrorLevel
addToPos=%Errorlevel%
SendMessage 0xB6, 0, ErrorLevel, Edit%tabNumber%, ahk_id %ControlID%
SendMessage 0xB1, pos + addToPos, pos + addToPos + Strlen(find), Edit%tabNumber%, ahk_id %ControlID%
offset := pos + addToPos + Strlen(find)
lastFind = %find%
hits++
SB_SetText("'" . find . "' found in line " . addToPos + 1, 1)
SB_SetText(hits . (hits = 1 ? " hit" : " hits"), 2)
Return |
_________________
SoggyDog
Dwarf Fortress:
"The most intriguing game I've ever played."
Last edited by SoggyDog on Mon Dec 22, 2008 10:37 pm; edited 6 times in total |
|
| Back to top |
|
 |
Fry
Joined: 01 Nov 2007 Posts: 885
|
Posted: Mon Dec 22, 2008 10:08 pm Post subject: |
|
|
Nice script, although one error
Today is displayed fine while say Tuesday is covered up by Todays text
EDIT
Oops i read your entire post and saw you wrote that down |
|
| Back to top |
|
 |
Frankie
Joined: 02 Nov 2008 Posts: 2850
|
Posted: Wed Dec 24, 2008 6:48 pm Post subject: |
|
|
I just tried it out and it works great. Thanks for the helpful script  _________________ aboutscript ⍟ apps ⍟ scripts
Any code ⇈ above ⇈ requires AutoHotkey_L to run |
|
| Back to top |
|
 |
RobOtter
Joined: 30 Jan 2005 Posts: 133 Location: Darmstadt, Germany
|
Posted: Sun Jan 11, 2009 1:52 pm Post subject: |
|
|
Hi,
nice script, looks fine! Unfortunately, I´m living in Germany - so, no weather info for me, all six info pages are blank
Any chance to map to another, an international forecast service?
Another wish would be to have some icons of course...
so long,
Rob |
|
| Back to top |
|
 |
small_c0d3r
Joined: 29 Nov 2009 Posts: 46 Location: Queensland
|
Posted: Fri Feb 19, 2010 7:47 am Post subject: |
|
|
whould there be a way to intergrate our own local weather sites
eg for Australia; [url]www.bom.gov.au
would make it very adaptable
PLZ reply as i am extremely interested
[/url] |
|
| Back to top |
|
 |
garry
Joined: 19 Apr 2005 Posts: 2212 Location: switzerland
|
Posted: Mon Feb 22, 2010 6:12 pm Post subject: |
|
|
no solution, just an idea for a minibrowser
name this script as >> Australia_Weather.hta
| Code: | <HTML>
<HEAD><TITLE>Browser</TITLE></HEAD>
<BODY>
<META HTTP-EQUIV="Refresh" CONTENT="0 URL=http://www.bom.gov.au/">
</BODY>
</HTML>
|
|
|
| Back to top |
|
 |
small_c0d3r
Joined: 29 Nov 2009 Posts: 46 Location: Queensland
|
Posted: Tue Feb 23, 2010 6:49 am Post subject: |
|
|
| but where in the script, weather.ahk, could you change the source of the informaion |
|
| Back to top |
|
 |
Jeremiah
Joined: 20 Apr 2009 Posts: 797 Location: North Dakota, USA
|
Posted: Tue Feb 23, 2010 4:52 pm Post subject: |
|
|
Hey, I just found this and tried it. Working great for me on Windows 7. I love it, actually. Thank you for this! _________________ -Jeremiah |
|
| 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
|