script not works / url changed
see new 20180930 PACIFIC weather warnings typhoon ( China Korea Japan Philippines )
https://autohotkey.com/boards/viewtopic ... 28&t=56707
example with https://weather.yahoo.com
Code: Select all
Modified=20140525
;- idea from user SKAN -----
;- Weather forecast in tray , Suzhou, Jiangsu
/*
how to get yahoo id for cities =
https://weather.yahoo.com/belgium/antwerp/antwerp-966591/
search for this above and type in your city >> see id XXXX ( &u=c > Celsius / &u=f Fahrenheit )
url=http://weather.yahooapis.com/forecastrss?w=XXXX&u=c
*/
#persistent
;-Suzhou, Jiangsu
url=http://weather.yahooapis.com/forecastrss?w=2137082&u=c ;Your City
Menu, Tray, NoStandard
Menu, tray, add, Show, MenuHandler
Menu, tray, add, Exit, MenuHandler
hObject:=ComObjCreate("WinHttp.WinHttpRequest.5.1") ;Create the Object
text=
ComObjError(false)
hObject.Open("GET",url) ;Open communication
hObject.Send() ;Send the "get" request
xml=
xml:=hObject.ResponseText ;Set the "xml" variable to the response
Title := StrX( XML, "<description>",1,13, "</description>",1,14 )
Text := ComUnHTML( StrX( XML, "Current Conditions:",1,19, "<a href",1,7 ) )
TrayTip, %Title%, %Text%,, 1
Return
MenuHandler:
If (A_ThisMenuItem = "Show")
TrayTip, %Title%, %Text%,, 1
If (A_ThisMenuItem = "Exit")
ExitApp
return
;-----------------------
;- user SKAN
;- http://www.autohotkey.com/board/topic/47368-strx-auto-parser-for-xml-html/
StrX( H, BS="",BO=0,BT=1, ES="",EO=0,ET=1, ByRef N="" ) { ; | by Skan | 19-Nov-2009
Return SubStr(H,P:=(((Z:=StrLen(ES))+(X:=StrLen(H))+StrLen(BS)-Z-X)?((T:=InStr(H,BS,0,((BO<0)?(1):(BO))))?(T+BT):(X+1)):(1)),(N:=P+((Z)?((T:=InStr(H,ES,0,((EO)?(P+1):(0))))?(T-P+Z +(0-ET)):(X+P)):(X)))-P)
; v1.0-196c 21-Nov-2009 www.autohotkey.com/forum/topic51354.html
}
;------------------------
;- user guests
;- http://www.autohotkey.com/board/topic/47356-unhtm-remove-html-formatting-from-a-string-updated/page-2
ComUnHTML(html) {
oHTML := ComObjCreate("HtmlFile")
oHTML.write(html)
return oHTML.documentElement.innerText
}
;===================== end script ===========================