Jump to content

Archived

This topic is now archived and is closed to further replies.

chain

Google Weather Toolbar

Recommended Posts

  • Administrators

Google Weather Toolbar

 

logo.jpg

 

doax60.jpg

 

2llo7bn.jpg

 

This script uses Googles "secret" Weather api To gather some weather information and images. The information and images are then sent to a picture window and the image is copied and added to the Toolbar.

Using the Script:

 

• Paste this code to a new Remote

 

• Edit the top of the script so %MyLocation reflects your home location. (Keep in mind that this does not accept airport codes. It's also a little picky, so it's better to use the two character abbreviation for your country. ie. CA for Canada. If you are in USA zipcodes work fine.)

 

• Save the script.

 

• Right click channel or status, goto Google Weather, and click On.

 

• Select dialog to search other cities or to see your forecast.

 

 

Additional information:

 

• Hover over the weather icon on the toolbar for more weather info.

 

• Click the weather icon to open the forecast dialog.

 

• You may also change the temperature from F to C. (See the setup at the top of the script)

 

 

>;Google ToolBar Weather by Ford_Lawnmower irc.GeekShed.net #Script-Helpalias GweatherTBInit {  ;;;;;Setup;;;;;  ;;Change %MyLocation to the location you want to monitor.  ;;**Note** This does NOT accept airport codes. City,State-City,Country or ZipCode.  var %MyLocation Hamilton,Ohio  ;;Change %ForC to F or C for the Measurement Unit you want to use.  var %ForC F  ;;Change %MPHorKPH to KPH if you want to view the wind in KPH.  var %MPHorKPH MPH  ;;;End Setup;;;  if (!$isdir(GoogleWeatherTB)) mkdir GoogleWeatherTB  writeini GoogleWeatherTB\GoogleWeatherTB.ini Settings MeasurementUnit %ForC  writeini GoogleWeatherTB\GoogleWeatherTB.ini Settings Location %MyLocation  writeini GoogleWeatherTB\GoogleWeatherTB.ini Settings WindMeasurement %MPHorKPH  window -hp +d @GoogleWeather 535 0 63 22  drawfill -r @GoogleWeather $rgb(240,240,230) $rgb(240,240,240) 0 0  GetGoogleWeather Window 0 %MyLocation  .timerGoogleWeatherTB -o 0 100 GetGoogleWeather Window 0 %MyLocation}on *:Start: {  if ($readini(GoogleWeatherTB\GoogleWeatherTB.ini,Settings,Status) != Off) GweatherTBInit}On *:Unload: .timerGoogleWeatherTB offalias -l GetGoogleWeather {  if (!$window(@GoogleWeather)) window -hp +d @GoogleWeather 535 0 63 22  .sockclose G.o.o.gleWeatherTB  sockopen G.o.o.gleWeatherTB www.google.com 80  sockmark G.o.o.gleWeatherTB $1 $+(/ig/api?weather=,$urlencode($3-)) $2}On *:sockopen:G.o.o.gleWeatherTB: {  if (!$sockerr) {    sockwrite -nt $sockname GET $gettok($sock($sockname).mark,2,32) HTTP/1.1    sockwrite -n $sockname User-Agent: Opera 9.6    sockwrite -n $sockname Host: $sock($sockname).addr    sockwrite -n $sockname $crlf  }  else { sockclose $sockname | return }}On *:sockread:G.o.o.gleWeatherTB: {  if ($sockerr) { sockclose $sockname | return }  else {    var %GoogleWeather | sockread %GoogleWeather    var %OutputMethod $gettok($sock($sockname).mark,1,32)    if ( isin %GoogleWeather && %OutputMethod == Dialog) {      did -ra GoogleWeather 2 $did(GoogleWeather,28) :: No Data found for $did(GoogleWeather,28)    }    if ($regex(%GoogleWeather,//i)) {      if (%OutputMethod == Dialog) {        dialog $iif($dialog(GoogleWeather),-v,-m GoogleWeather) GoogleWeather        did -ra GoogleWeather 2 $regml(1) on $fulldate      }      else sockmark $sockname $addtok($sock($sockname).mark,$regml(1),13)    }    if ($regex(%GoogleWeather,//i)) {      if (%OutputMethod == Dialog) did -ra GoogleWeather 32 $regml(1)      else sockmark $sockname $addtok($sock($sockname).mark,$regml(1),13)    }    if ($regex(%GoogleWeather,//i)) {      var %wind $MPH-KPH($regml(1))      if (%OutputMethod == Dialog) did -ra GoogleWeather 33 %wind      else sockmark $sockname $addtok($sock($sockname).mark,%wind,13)    }    if ($regex(%GoogleWeather,//gi) && %OutputMethod == Dialog) {      var %count 1      while (%count = 6) {          GetGoogleWeatherIcon $regml($calc(%c - 2)) $+($regml($calc(%c - 1)),/,$regml(%c)) GoogleWeatherTB $regml(%c) %OutputMethod %cc          dec %c 3          dec %cc        }      }    }  }}alias -l UpdateToolBar {  drawsave @GoogleWeather GoogleWeatherTB\GoogleWeather.jpg  if ($toolbar(GoogleWeather)) {     toolbar $1 GoogleWeather $qt($2-) "GoogleWeatherTB\GoogleWeather.jpg" $&      $qt(/GetGoogleWeather Dialog 0 $readini(GoogleWeatherTB\GoogleWeatherTB.ini,Settings,Location)) @GoogleWeather  }  else {    toolbar -as GoogleWeather|    toolbar -a GoogleWeather $qt($2-) "GoogleWeatherTB\GoogleWeather.jpg" $&      $qt(/GetGoogleWeather Dialog 0 $readini(GoogleWeatherTB\GoogleWeatherTB.ini,Settings,Location)) @GoogleWeather  }}alias -l GetGoogleWeatherIcon {  if ($isfile($qt($+($3,\,$4)))) {     if ($5 == Window) drawpic -ns @GoogleWeather 0 0 25 22 $+(GoogleWeatherTB/,$4)    elseif (($5 == Dialog)) did -g GoogleWeather $iif($6,$calc($6 + 9),$+(3,$chr(44),11)) $qt($+(GoogleWeatherTB/,$4))  }  else {    var %sockname $+(GetGoogleWeatherIcon,$ticks,$r(1,$ticks))    if (!$isdir($qt($3))) { mkdir $qt($3) }    sockopen %sockname $1 80    sockmark %sockname $1-  }}On *:sockopen:GetGoogleWeatherIcon*:{  sockwrite -nt $sockname GET $+(/,$gettok($sock($sockname).mark,2,32)) HTTP/1.0  sockwrite -n $sockname Host: $gettok($sock($sockname).mark,1,32) $+ $crlf $+ $crlf}On *:sockread:GetGoogleWeatherIcon*:{  if (!$gettok($sock($sockname).mark,7,32)) {    var %GetGoogleWeatherIcon | sockread %GetGoogleWeatherIcon    if (!%GetGoogleWeatherIcon) { sockmark $sockname $addtok($sock($sockname).mark,1,32) }  }  else {    sockread &GetGoogleWeatherIcon    bwrite -s $qt($+($gettok($sock($sockname).mark,3,32),\,$gettok($sock($sockname).mark,4,32))) -1 -1 &GetGoogleWeatherIcon  }}On *:sockclose:GetGoogleWeatherIcon*:{  tokenize 32 $sock($sockname).mark  if ($exists($qt($+($3,/,$4)))) {    if ($5 == Window) {      drawpic -s @GoogleWeather 0 0 25 22 $qt($+($3,/,$4))    }    elseif ($5 == Dialog) {      if (!$6) did -g GoogleWeather 3,11 $qt($+($3,/,$4))      else did -g GoogleWeather $calc(9 + $6) $qt($+($3,/,$4))    }  }}alias -l MPH-KPH {  if ($readini(GoogleWeatherTB\GoogleWeatherTB.ini,Settings,WindMeasurement) == KPH) {    return $replace($regsubex($1-,/([\d]+)/,$round($calc(\t * 1.609344),0)),mph,kph)  }  else return $1-}alias -l ForC {  if ($readini(GoogleWeatherTB\GoogleWeatherTB.ini,Settings,MeasurementUnit) == C) {    return $round($calc((5 / 9) * ($1 - 32)),0)  }  else return $1}alias -l urlencode return $replace($regsubex($1-,/([^a-z0-9\s])/ig,% $+ $base($asc(\t),10,16,2)),$chr(32),+)menu @GoogleWeather {  Google Weather  .$iif($timer(GoogleWeatherTB),$style(3)) On:{    writeini GoogleWeatherTB\GoogleWeatherTB.ini Settings Status On    GweatherTBInit  }  .$iif(!$timer(GoogleWeatherTB),$style(3)) Off:{    .timerGoogleWeatherTB off    window -c @GoogleWeather    if ($toolbar(GoogleWeather)) toolbar -d GoogleWeather    if ($toolbar(GoogleWeather|)) toolbar -d GoogleWeather|    writeini GoogleWeatherTB\GoogleWeatherTB.ini Settings Status Off  }  .Dialogs:dialog $iif($dialog(GoogleWeather),-v,-m GoogleWeather) GoogleWeather}menu channel,status,menubar {  -  Google Weather  .$iif($timer(GoogleWeatherTB),$style(3)) On:{    writeini GoogleWeatherTB\GoogleWeatherTB.ini Settings Status On    GweatherTBInit  }  .$iif(!$timer(GoogleWeatherTB),$style(3)) Off:{    .timerGoogleWeatherTB off    window -c @GoogleWeather    if ($toolbar(GoogleWeather)) toolbar -d GoogleWeather    if ($toolbar(GoogleWeather|)) toolbar -d GoogleWeather|    writeini GoogleWeatherTB\GoogleWeatherTB.ini Settings Status Off  }  .Dialogs:dialog $iif($dialog(GoogleWeather),-v,-m GoogleWeather) GoogleWeather}On *:dialog:GoogleWeather:Sclick:29: {  if ($did(28)) getgoogleweather dialog 0 $v1}dialog GoogleWeather {  title "Google Weather"  size -1 -1 232 129  option dbu  text "Current Weather for", 1, 5 2 52 8  text "", 2, 57 2 168 8  icon 3, 6 17 20 20  text "Condition:", 4, 34 14 27 8  text "Humidity:", 5, 34 24 27 8  text "Wind:", 6, 34 34 27 8  text "", 7, 9 54 54 8, center  text "", 8, 63 54 54 8, center  text "", 9, 117 54 54 8, center  text "", 10, 171 54 54 8, center  icon 11, 26 63 20 20  icon 12, 80 63 20 20  icon 13, 134 63 20 20  icon 14, 186 63 20 20  text "", 15, 9 87 25 8  text "", 16, 63 87 25 8  text "", 17, 117 87 25 8  text "", 18, 171 87 25 8  text "", 19, 34 87 29 8  text "", 20, 88 87 29 8  text "", 21, 142 87 29 8  text "", 22, 196 87 29 8  text "", 23, 9 96 54 16, center  text "", 24, 63 96 54 16, center  text "", 25, 117 96 54 16, center  text "", 26, 171 96 54 16, center  text "Location:", 27, 9 116 24 8  edit "", 28, 33 115 110 10, autohs  button "Check", 29, 148 114 37 12  button "Close", 30, 188 114 37 12, cancel  text "", 31, 61 14 164 8  text "", 32, 61 24 163 8  text "", 33, 61 34 163 8  text "", 34, 5 39 25 8, center  box "", 35, 170 49 54 64  box "", 36, 62 49 54 64  box "", 37, 116 49 54 64  box "", 38, 8 49 54 64}

Link to comment
Share on other sites



×
×
  • Create New...