Example: autohotkey get weather temperature
zipcode=57186 ;change 57186 to your zip code
updateseconds=300 ;Set Seconds between updates.
gui, add, Picture, vcurtemppic w30 h30
gui, add, text, vcurtemp w70 h30 x+5
gui, show
;update and set timer.
Gosub, updateweather
updateseconds:=updateseconds*1000 ;Convert to milliseconds
SetTimer, updateweather, %updateseconds%
Return
updateweather:
URLDownloadToFile, http://www.google.com/ig/api?weather=%zipcode%, weather.htm
FileRead, weatherxml, weather.htm
FileDelete, weather.htm
forcasthit=
loop, parse, weatherxml, `>`<
{
;Get Weather Image
IfInString, a_loopfield, forecast_conditions
forcasthit=1
if (!forcasthit)
{
;Get Temp in F
IfInString, a_loopfield, temp`_f
{
StringGetPos, quotestart, a_loopfield, `", L1
quotestart+=2
StringGetPos, quoteend, a_loopfield, `", L2
quoteend++
quotelen:=quoteend-quotestart
StringMid, curtemp, a_loopfield, quotestart, %quotelen%
GuiControl,,curtemp,%curtemp%°F`n%curcondition%
}
;Get condition
IfNotInString, a_loopfield, wind_condition data
{
IfInString, a_loopfield, condition data
{
StringGetPos, quotestart, a_loopfield, `", L1
quotestart+=2
StringGetPos, quoteend, a_loopfield, `", L2
quoteend++
quotelen:=quoteend-quotestart
StringMid, curcondition, a_loopfield, quotestart, %quotelen%
GuiControl,,curtemp,%curtemp%°F`n%curcondition%
}
}
IfInString, a_loopfield, icon data
{
StringGetPos, quotestart, a_loopfield, `", L1
quotestart+=2
StringGetPos, quoteend, a_loopfield, `", L2
quoteend++
quotelen:=quoteend-quotestart
StringMid, curtempimg, a_loopfield, quotestart, %quotelen%
curtempimg= http`:`/`/www.google.com%curtempimg%
URLDownloadToFile, %curtempimg%, curweather.jpg
GuiControl,,curtemppic,curweather.jpg
FileDelete, curweather.jpg
}
}
}
Return
GuiClose:
ExitApp