instPath = SystemPath( "ScriptPath" ) # turn everything OFF first KillScript("loop.mscr") RemoveNotifications(instPath&"\TitaniumWeather.exe") #RunOnPowerOn (instPath&"\TitaniumWeather.exe") # update interval set by user in minutes usertime = RegRead("HKLM","Software\TitaniumWeather","usertime")*60 forceupdate = RegRead("HKLM","Software\TitaniumWeather","forceupdate") # For manual updates (if usertime = 0, no scheduling is required) If (forceupdate && (usertime <> 0)) nextupdate = TimeStamp()+usertime RunAt(nextupdate, instPath&"\TitaniumWeather.exe") RegWriteDWord("HKLM","Software\TitaniumWeather","forceupdate",0) RegWriteDWord("HKLM","Software\TitaniumWeather","nextupdate",nextupdate) # For auto updates ElseIf (usertime > 0) offtime = RegRead("HKLM", "Software\TitaniumWeather","OFFtime") ontime = RegRead("HKLM", "Software\TitaniumWeather","ONtime") # make sure ON/OFF times are valid hours If ( (offtime >= 0) AND (offtime <= 24) AND (ontime >= 0) AND (ontime <= 24) ) GetTime(currhour,currmin,currsec,currday,currmonth,curryear) # no wrap-around at midnight (hour 0) If (offtime > ontime) If (currhour >= ontime) If (currhour < offtime) # ON nextupdate = TimeStamp()+usertime RegWriteDWord("HKLM","Software\TitaniumWeather","nextupdate",nextupdate) RunAt(nextupdate, instPath&"\TitaniumWeather.exe") Else # OFF - schedule for tomorrow RegWriteDWord("HKLM","Software\TitaniumWeather","fupdate",1) nextupdate = TimeStamp() + (ontime+24-currhour)*3600 - (currmin)*60 + Rand(300) RegWriteDWord("HKLM","Software\TitaniumWeather","nextupdate",nextupdate) RunAt(nextupdate, instPath&"\TitaniumWeather.exe") #Run(instPath&"\loop.exe") exit EndIf Else # OFF - schedule for today RegWriteDWord("HKLM","Software\TitaniumWeather","fupdate",1) nextupdate = TimeStamp() + (ontime-currhour)*3600 - (currmin)*60 + Rand(300) RegWriteDWord("HKLM","Software\TitaniumWeather","nextupdate",nextupdate) RunAt(nextupdate, instPath&"\TitaniumWeather.exe") #Run(instPath&"\loop.exe") exit EndIf # wrap-around midnight Else If ( (currhour < ontime) AND (currhour >= offtime) ) # OFF RegWriteDWord("HKLM","Software\TitaniumWeather","fupdate",1) nextupdate = TimeStamp() + (ontime-currhour)*3600 - (currmin)*60 + Rand(300) RegWriteDWord("HKLM","Software\TitaniumWeather","nextupdate",nextupdate) RunAt(nextupdate, instPath&"\TitaniumWeather.exe") #Run(instPath&"\loop.exe") exit Else # ON nextupdate = TimeStamp()+usertime RegWriteDWord("HKLM","Software\TitaniumWeather","nextupdate",nextupdate) RunAt(nextupdate, instPath&"\TitaniumWeather.exe") EndIf EndIf # invalid ON/OFF times or always update Else nextupdate = TimeStamp()+usertime RegWriteDWord("HKLM","Software\TitaniumWeather","nextupdate",nextupdate) RunAt(nextupdate, instPath&"\TitaniumWeather.exe") EndIf EndIf # do not try to update if a call is active, try again in 5 min If (RegRead("HKLM","System\State\Phone","Status") AND 537067520) RemoveNotifications(instPath&"\TitaniumWeather.exe") nextupdate = TimeStamp()+300 RunAt(nextupdate, instPath&"\TitaniumWeather.exe") RegWriteDWord("HKLM","Software\TitaniumWeather","nextupdate",nextupdate) exit EndIf ##################### If (RegValueExists("HKLM","Software\TitaniumWeather","fupdate")) fupdate = RegRead("HKLM", "Software\TitaniumWeather","fupdate") Else fupdate = 1 RegWriteDWord("HKLM","Software\TitaniumWeather","fupdate",fupdate) EndIf userauto = RegRead("HKLM", "Software\TitaniumWeather","userauto") location = RegRead("HKLM", "Software\TitaniumWeather","code") units = RegRead("HKLM", "Software\TitaniumWeather","units") startconn = RegRead("HKLM", "Software\TitaniumWeather","Connect") If (usertime = 0) fupdate = 1 EndIf If (units eq "F") metric = 0 windunits = " mph" distunits = " miles" precipunits = " in" Else metric = 1 windunits = " kph" distunits = " km" precipunits = " mm" EndIf #Update Panel RegWriteDWord ("HKLM", "Software\Microsoft\CHome\TitaniumWeather","Updated","0") RegWriteString ("HKLM", "Software\Microsoft\CHome\TitaniumWeather\Page1","Time","AccuWeather·Î ¿¬°á Áß") RegWriteDWord ("HKLM", "Software\Microsoft\CHome\TitaniumWeather","Updated","1") If (startconn) Sleep 500 EndIf If(InternetConnected("http://google.com/m")) Call Accuweather #Update Panel RegWriteString ("HKLM", "Software\Microsoft\CHome\TitaniumWeather\Page1","Time","¾÷µ¥ÀÌÆ® Àû¿ë Áß") RegWriteDWord ("HKLM", "Software\Microsoft\CHome\TitaniumWeather","Updated","1") units = ToUpper(units) Call WriteCurrent If (fupdate = 1) Call WriteForecast EndIf If (fupdate >= userauto) fupdate = 1 RegWriteDWord("HKLM","Software\TitaniumWeather","fupdate",fupdate) Else fupdate = fupdate + 1 RegWriteDWord("HKLM","Software\TitaniumWeather","fupdate",fupdate) EndIf #Update Panel RegWriteString ("HKLM", "Software\Microsoft\CHome\TitaniumWeather\Page1","Time","¾÷µ¥ÀÌÆ® ¿Ï·á") RegWriteDWord ("HKLM", "Software\Microsoft\CHome\TitaniumWeather","Updated","0") # if no internet, try again in 15 minutes Else RemoveNotifications(instPath&"\TitaniumWeather.exe") nextupdate = TimeStamp()+900 RunAt(nextupdate, instPath&"\TitaniumWeather.exe") RegWriteDWord("HKLM","Software\TitaniumWeather","nextupdate",nextupdate) #Update Panel RegWriteString ("HKLM", "Software\Microsoft\CHome\TitaniumWeather\Page1","Time","¿¬°á ºÒ°¡?!") RegWriteDWord ("HKLM", "Software\Microsoft\CHome\TitaniumWeather","Updated","0") Sleep(5000) oldtemp = RegRead("HKLM", "Software\Microsoft\CHome\TitaniumWeather\Page1","TodayTemps") oldtemp =substr(oldtemp, 1, 10) RegWriteString ("HKLM", "Software\Microsoft\CHome\TitaniumWeather\Page1","CurrentIcon",instPath&"\condicons\na.png") RegWriteString ("HKLM", "Software\Microsoft\CHome\TitaniumWeather\Page1","CurrentTemp"," ") RegWriteString ("HKLM", "Software\Microsoft\CHome\TitaniumWeather\CondensedPage","PluginLabel",oldtemp) RegWriteDWord ("HKLM", "Software\Microsoft\CHome\TitaniumWeather","Updated","1") exit EndIf RegWriteString ("HKLM", "Software\Microsoft\CHome\TitaniumWeather\Page1","Time",City&", "&updatetime&"¿¡ °»½Å") RegWriteDWord ("HKLM", "Software\Microsoft\CHome\TitaniumWeather","Updated","1") Call FullscreenWeather wmsg=1 Return(wmsg) Exit ########################################### Sub AccuWeather link=ReadFile("http://wwwa.accuweather.com/adcbin/forecastfox/weather_data.asp?location="&location&"&metric="&metric) Split(link, "")) #Update Panel RegWriteString ("HKLM", "Software\Microsoft\CHome\TitaniumWeather\Page1","Time","ãÀ» ¼ö ¾ø´Â Áö¿ªÀÔ´Ï´Ù.") RegWriteDWord ("HKLM", "Software\Microsoft\CHome\TitaniumWeather","Updated","0") Exit EndIf #Update Panel RegWriteString ("HKLM", "Software\Microsoft\CHome\TitaniumWeather\Page1","Time","ÇöÀç ³¯¾¾¸¦ °¡Á®¿À°í ÀÖ½À´Ï´Ù.") RegWriteDWord ("HKLM", "Software\Microsoft\CHome\TitaniumWeather","Updated","0") daynum = 1 ##Get Current pos = Find(curdata,"") If (pos) pos = pos + 6 len = Find(curdata, "",pos)-pos CityTemp = SubStr(curdata,pos,len) ######### ## For localization ######### CallFunction("LocalizationCity", City, CityTemp) EndIf updatetime = FormatTime("H:i") #pos = Find(curdata,"",pos)-pos # bar = SubStr(curdata,pos,len) # bar = Replace(bar,""">"," ") #EndIf pos = Find(curdata,"") If (pos) pos = pos + 13 len = Find(curdata, "",pos)-pos ctemp = SubStr(curdata,pos,len) EndIf pos = Find(curdata,"") If (pos) pos = pos + 10 len = Find(curdata, "",pos)-pos realfeel = SubStr(curdata,pos,len) EndIf pos = Find(curdata,"") If (pos) pos = pos + 13 len = Find(curdata, "",pos)-pos ccode = SubStr(curdata,pos,len) EndIf pos = Find(curdata,"") If (pos) pos = pos + 10 len = Find(curdata, "",pos)-pos humidity = SubStr(curdata,pos,len) EndIf pos = Find(curdata,"") If (pos) pos = pos + 13 len = Find(curdata, "",pos)-pos ccondtemp = SubStr(curdata,pos,len) ##### ## for localization ##### CallFunction("LocalizationWeather", ccond, ccondtemp) ##### EndIf pos = Find(curdata,"") If (pos) pos = pos + 12 len = Find(curdata, "",pos)-pos vis = SubStr(curdata,pos,len) EndIf pos = Find(curdata,"",pos)-pos uvindex = SubStr(curdata,pos,len) uvindex = Replace(uvindex,""">"," (")&")" EndIf pos = Find(curdata,"") If (pos) pos = pos + 10 len = Find(curdata, "",pos)-pos dewpt = SubStr(curdata,pos,len) EndIf pos = Find(curdata,"") If (pos) pos = pos + 12 len = Find(curdata, "%",pos)-pos clouds = SubStr(curdata,pos,len) # can't get round function to word clouds = part(clouds,".",1) & "%" EndIf pos = Find(curdata,"") If (pos) pos = pos + 11 len = Find(curdata, "",pos)-pos cwindspeed = SubStr(curdata,pos,len) EndIf pos = Find(curdata,"") If (pos) pos = pos + 15 len = Find(curdata, "",pos)-pos cwinddir = SubStr(curdata,pos,len) If(cwinddir eq "CLM") cwinddir = "Calm" EndIf EndIf pos = Find(curdata,"") If (pos) pos = pos + 8 len = Find(curdata, "",pos)-pos cprecip = SubStr(curdata,pos,len) EndIf ##Get wind gust pos = Find(forecastdata[1],"") If (pos) pos = pos + 10 len = Find(forecastdata[1], "",pos)-pos cwindgust = SubStr(forecastdata[1],pos,len) EndIf #end Get Current ##Get Forecast If (fupdate = 1) For i = 1 to 5 step 1 Call("Forecast", forecastdata[i]) Next EndIf EndSub ######################### Sub Forecast fdata = argv[1] pos = Find(fdata,"number=") if(pos) daynum = SubStr(fdata,pos+8,1) #Update Panel RegWriteDWord ("HKLM", "Software\Microsoft\CHome\TitaniumWeather","Updated","1") RegWriteString ("HKLM", "Software\Microsoft\CHome\TitaniumWeather\Page1","Time", daynum&"ÈÄ ³¯¾¾ °»½Å Áß") RegWriteDWord ("HKLM", "Software\Microsoft\CHome\TitaniumWeather","Updated","0") pos = Find(fdata,"") If (pos) pos = pos + 9 endspot = Find(fdata,"",pos)-pos date[daynum] = SubStr(fdata,pos,endspot) EndIf pos = Find(fdata,"") If (pos) pos = pos + 9 endspot = Find(fdata,"",pos)-pos daytemp = SubStr(fdata,pos,endspot) ### CallFunction("LocalizationDaycode", day[daynum], daytemp) ### EndIf pos = Find(fdata,"") If (pos) pos = pos + 9 endspot = Find(fdata,"",pos)-pos sunrise[daynum] = SubStr(fdata,pos,endspot) EndIf pos = Find(fdata,"") If (pos) pos = pos + 8 endspot = Find(fdata,"",pos)-pos sunset[daynum] = SubStr(fdata,pos,endspot) EndIf pos = Find(fdata,"") If (pos) pos = pos + 10 endspot = Find(fdata,"",pos)-pos shortdesc[daynum] = SubStr(fdata,pos,endspot) EndIf pos = Find(fdata,"") If (pos) pos = pos + 13 endspot = Find(fdata,"",pos)-pos icon[daynum] = SubStr(fdata,pos,endspot) EndIf pos = Find(fdata,"") If (pos) pos = pos + 17 endspot = Find(fdata,"",pos)-pos high[daynum] = SubStr(fdata,pos,endspot) EndIf pos = Find(fdata,"") If (pos) pos = pos + 16 endspot = Find(fdata,"",pos)-pos low[daynum] = SubStr(fdata,pos,endspot) EndIf pos = Find(fdata,"") If (pos) pos = pos + 14 endspot = Find(fdata,"",pos)-pos realfeelhi[daynum] = SubStr(fdata,pos,endspot) EndIf pos = Find(fdata,"") If (pos) pos = pos + 13 endspot = Find(fdata,"",pos)-pos realfeello[daynum] = SubStr(fdata,pos,endspot) EndIf pos = Find(fdata,"") If (pos) pos = pos + 11 endspot = Find(fdata,"",pos)-pos windspeed[daynum] = SubStr(fdata,pos,endspot) EndIf pos = Find(fdata,"") If (pos) pos = pos + 15 endspot = Find(fdata,"",pos)-pos winddir[daynum] = SubStr(fdata,pos,endspot) EndIf pos = Find(fdata,"") If (pos) pos = pos + 10 endspot = Find(fdata,"",pos)-pos windgust[daynum] = SubStr(fdata,pos,endspot) EndIf pos = Find(fdata,"") If (pos) pos = pos + 7 endspot = Find(fdata,"",pos)-pos uv[daynum] = SubStr(fdata,pos,endspot) EndIf pos = Find(fdata,"") If (pos) pos = pos + 14 endspot = Find(fdata,"",pos)-pos prec[daynum] = SubStr(fdata,pos,endspot) EndIf pos = Find(fdata,"") If (pos) pos = pos + 12 endspot = Find(fdata,"",pos)-pos tstormprob[daynum] = SubStr(fdata,pos,endspot) EndIf EndIf EndSub ######################## Sub WriteCurrent RegWriteString ("HKLM", "Software\Microsoft\CHome\TitaniumWeather\CondensedPage","PluginLabel",ctemp&"¡É/ "&ccond) RegWriteString ("HKLM", "Software\Microsoft\CHome\TitaniumWeather\Page1","CurrentIcon",instPath&"\condicons\"&ccode&".png") RegWriteString ("HKLM", "Software\Microsoft\CHome\TitaniumWeather\Page1","CurrentTemp",ctemp&"¡É") # write current detail page RegWriteString ("HKLM", "Software\Microsoft\CHome\TitaniumWeather\Page2","CurrentIcon",instPath&"\condicons\"&ccode&".png") RegWriteString ("HKLM", "Software\Microsoft\CHome\TitaniumWeather\Page2","CurrentTemp2",ctemp&"¡É") RegWriteString("HKLM","Software\Microsoft\CHome\TitaniumWeather\Page2","Desc",City&"ÀÇ Ã¼°¨¿Âµµ: "&realfeel&"¡É" ) RegWriteString("HKLM","Software\Microsoft\CHome\TitaniumWeather\Page2","Winds","¹Ù¶÷: "&cwinddir&" "&cwindspeed&windunits&", ÃÖ´ëdz¼Ó: "&cwindgust) RegWriteString("HKLM","Software\Microsoft\CHome\TitaniumWeather\Page2","Prec","°­¼ö·®: "&cprecip&" "&precipunits&", °¡½Ã°Å¸®: "&vis&" "&distunits) RegWriteString("HKLM","Software\Microsoft\CHome\TitaniumWeather\Page2","Other","±¸¸§: "&clouds&", ½Àµµ: "&humidity) #Write to S2U2 If (RegKeyExists("HKCU","Software\A_C\S2U2")) RegWriteString("HKCU","Software\A_C\S2U2","UserWeather","C|"&ccode&"|"&ctemp&", Feels Like "&realfeel) EndIf EndSub ######################## Sub WriteForecast dct = 2 # format forecast days For ct = 1 to 5 step 1 shortday = SubStr(day[ct], 1, 1) # shortday = ToUpper(shortday) dct = dct + 1 # Only update the number of forecast days received (only 4 days are received around 12am - 2am) RegWriteDWord("HKLM","Software\TitaniumWeather","forecastdays", daynum) If (daynum >= ct) RegWriteString("HKLM","Software\Microsoft\CHome\TitaniumWeather\Page1","Day"&ct&"Icon",instPath&"\condicons\"&icon[ct]&".png") Else RegWriteString("HKLM","Software\Microsoft\CHome\TitaniumWeather\Page1","Day"&ct&"Icon",instPath&"\condicons\blank.png") EndIf # Write forecast detail pages RegWriteString("HKLM","Software\Microsoft\CHome\TitaniumWeather\Page"&dct,"Day",day[ct]&", "&date[ct]) RegWriteString("HKLM","Software\Microsoft\CHome\TitaniumWeather\Page"&dct,"Desc",shortdesc[ct]) RegWriteString("HKLM","Software\Microsoft\CHome\TitaniumWeather\Page"&dct,"Temps",high[ct]&"/"&low[ct]) RegWriteString("HKLM","Software\Microsoft\CHome\TitaniumWeather\Page"&dct,"Winds",winddir[ct]&" "&windspeed[ct]&windunits&", ÃÖ´ëdz¼Ó: "&windgust[ct]) RegWriteString("HKLM","Software\Microsoft\CHome\TitaniumWeather\Page"&dct,"Prec","°­¼öÈ®À²: "&tstormprob[ct]&"%, Àڿܼ± ·¹º§: "&uv[ct]) RegWriteString("HKLM","Software\Microsoft\CHome\TitaniumWeather\Page"&dct,"Other","ÀÏÃâ: "&sunrise[ct]&", Àϸô: "&sunset[ct]) RegWriteString("HKLM","Software\Microsoft\CHome\TitaniumWeather\Page"&dct,"ForecastIcon",instPath&"\condicons\"&icon[ct]&".png") RegWriteString("HKLM","Software\Microsoft\CHome\TitaniumWeather\Page1","Day"&ct,shortday&"^CR^"&high[ct]&"/"&low[ct]) Next RegWriteString ("HKLM", "Software\Microsoft\CHome\TitaniumWeather\Page1","TodayTemps",high[1]&"¡É/"&low[1]&"¡É") RegWriteString ("HKLM", "Software\Microsoft\CHome\TitaniumWeather\Page2","TodayTemps",high[1]&"¡É/"&low[1]&"¡É") EndSub ############ ## for localization ## Created by minyk ############ Sub LocalizationWeather ldata = argv[1] ret = "" If (ldata eq "Clear") ret = "±¸¸§ ¾øÀ½" ElseIf (ldata eq "Light Fog") ret = "¾àÇÑ ¾È°³" ElseIf (ldata eq "Rain") ret = "ºñ" ElseIf (ldata eq "Cloudy") ret = "È帮°í ±¸¸§ ¸¹À½" ElseIf (ldata eq "Mostly Cloudy") ret = "È帮°í ±¸¸§ ¸¹À½" ElseIf (ldata eq "Fog") ret = "¾È°³" ElseIf (ldata eq "Partly Cloudy") ret = "±¸¸§ Á¶±Ý" ElseIf (ldata eq "Partly Sunny") ret ="¾à°£ È帲" ElseIf (ldata eq "Snow") ret ="´«" ElseIf (ldata eq "Light Snow") ret ="¾àÇÑ ´«" ElseIf (ldata eq "Sunny") ret = "¸¼À½" ElseIf (ldata eq "Mostly Sunny") ret ="´ëºÎºÐ ¸¼À½" ElseIf (ldata eq "Fog with rain and drizzle") ret ="¾È°³¸¦ µ¿¹ÝÇÑ ºñ" Else ret = ldata EndIf Return (ret) EndSub #### Sub LocalizationCity cdata = argv[1] ret = "" If (cdata eq "Seoul") ret = "¼­¿ï" ElseIf (cdata eq "INCHEON") ret = "ÀÎõ" Else ret = cdata EndIf Return (ret) EndSub ####### Sub LocalizationDaycode ddata = argv[1] ret = "" If (ddata eq "Monday") ret = "¿ù¿äÀÏ" ElseIf (ddata eq "Tuesday") ret = "È­¿äÀÏ" ElseIf (ddata eq "Wednesday") ret = "¼ö¿äÀÏ" ElseIf (ddata eq "Thursday") ret = "¸ñ¿äÀÏ" ElseIf (ddata eq "Friday") ret = "±Ý¿äÀÏ" ElseIf (ddata eq "Saturday") ret = "Åä¿äÀÏ" Else ret = "ÀÏ¿äÀÏ" EndIf Return (ret) EndSub ######################## ###slovenec88########### Sub FullscreenWeather Fullnumber = RegRead ("HKLM","Software\Microsoft\CHome\TitaniumWeather\Page1","CurrentIcon") Fullnumber = SubStr(Fullnumber, -6) Copy("\Program Files\TitaniumWeather\Fullscreen\" & Fullnumber ,"\Windows\titaniumweather.png",TRUE) RedrawToday EndSub #######