Weather forecast for Suzhou Jiangsu

许多实用脚本和封装函数, 可以让您编写脚本更加便捷高效

Moderators: tmplinshi, arcticir

Post Reply
garry
Posts: 3763
Joined: 22 Dec 2013, 12:50

Weather forecast for Suzhou Jiangsu

Post by garry » 25 May 2014, 07:54

EDIT :
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 ===========================

Last edited by garry on 30 Sep 2018, 13:20, edited 1 time in total.
User avatar
amnesiac
Posts: 186
Joined: 22 Nov 2013, 03:08
Location: Egret Island, China
Contact:

Re: Weather forecast for Suzhou Jiangsu

Post by amnesiac » 25 May 2014, 20:57

Hello, garry. Are you interested in China? Can you speak Chinese?

PS: I move this subject to "脚本函数".
AutoHotkey 学习指南(Beauty of AutoHotkey)
I do not make codes, and only a porter of AutoHotkey: from official to Chinese, from other languages to AutoHotkey, and show AutoHotkey to ordinary users sometimes.
garry
Posts: 3763
Joined: 22 Dec 2013, 12:50

Re: Weather forecast for Suzhou Jiangsu

Post by garry » 26 May 2014, 01:49

Thank you amnesiac to move this to "脚本函数" , hoping not disturbs when I put some small scripts here
I can't speak/write/read chinese, I visited my son in Suzhou / Jiangsu , he worked there
China is very interesting big modern country
Most products I use are made in China
User avatar
amnesiac
Posts: 186
Joined: 22 Nov 2013, 03:08
Location: Egret Island, China
Contact:

Re: Weather forecast for Suzhou Jiangsu

Post by amnesiac » 26 May 2014, 10:25

garry wrote:Thank you amnesiac to move this to "脚本函数" , hoping not disturbs when I put some small scripts here
I can't speak/write/read chinese, I visited my son in Suzhou / Jiangsu , he worked there
China is very interesting big modern country
Most products I use are made in China
I see. I'm not far from Jiangsu. Haha, maybe he could help to improve my English.
You can post your scripts for free.
请求帮助: request for help
脚本函数: scripts & functions
AutoHotkey 学习指南(Beauty of AutoHotkey)
I do not make codes, and only a porter of AutoHotkey: from official to Chinese, from other languages to AutoHotkey, and show AutoHotkey to ordinary users sometimes.
garry
Posts: 3763
Joined: 22 Dec 2013, 12:50

Re: Weather forecast for Suzhou Jiangsu

Post by garry » 26 May 2014, 10:48

Thank you amnesiac for your help
my english is not well , I speak german
I made a failure, I know , the first part is : "request for help" / "请求帮助" and the second is : "scripts & functions" / "脚本函数"
xie xie / 謝謝 , greetings from switzerland
Post Reply

Return to “脚本函数”