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:
;Google ToolBar Weather by Ford_Lawnmower irc.GeekShed.net #Script-Help
; .______________________
; _____ | \______ \_ ___ \
; / \| || _/ \ \/
;| Y Y \ || | \ \____
;|__|_| /___||____|_ /\______ /
; \/ \/ \/
alias 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 off
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
}
alias -l GetGoogleWeather {
.sockclose G.o.o.g.leWeatherTB
.remove googleweathertemp.txt
if (!$window(@GoogleWeather)) window -hp +d @GoogleWeather 535 0 63 22
sockopen G.o.o.g.leWeatherTB www.google.com 80
sockmark G.o.o.g.leWeatherTB $1 $+(/search?ie=UTF-8&q=weather+,$replace($3-,$chr(32),+)) $2
}
On *:sockopen:G.o.o.g.leWeatherTB: {
if (!$sockerr) {
sockwrite -nt $sockname GET $gettok($sock($sockname).mark,2,32) HTTP/1.0
sockwrite -n $sockname Host: www.google.com
sockwrite -n $sockname $crlf
}
else { echo -st Socket Error $nopath($script) | sockclose $sockname | return }
}
On *:sockread:G.o.o.g.leWeatherTB: {
if ($sockerr) { echo -st Socket Error $nopath($script) | sockclose $sockname | return }
else {
sockread -fn &googleweather
bwrite googleweathertemp.txt $file(googleweathertemp.txt).size $bvar(&googleweather,0) &googleweather
bread googleweathertemp.txt 1 $file(googleweathertemp.txt).size &googleweather
var %OutputMethod $gettok($sock($sockname).mark,1,32)
if ($bintween(&googleweather,class="e",</div>,1)) {
var %start $bfind(&googleweather, 1, class="e"), %finish $bfind(&googleweather, %start, </div>)
bcopy -c &googleweather 1 &googleweather %start $calc(%finish - %start)
sockclose $sockname
.remove googleweathertemp.txt
if (%OutputMethod == Window) {
clear @GoogleWeather
drawfill -r @GoogleWeather $rgb(240,240,230) $rgb(240,240,240) 0 0
}
if ($bintween(&googleweather,<h3><b>Weather</b> for <b>,</h3>,1)) {
var %location $remove($v1,<b>,</b>)
if (%OutputMethod == Dialog) {
dialog $iif($dialog(GoogleWeather),-v,-m GoogleWeather) GoogleWeather
did -ra GoogleWeather 2 %location on $fulldate
}
}
if ($bintween(&googleweather,src="//,",1)) {
GetGoogleWeatherIcon $gettok($v1,1,47) $replace($+(/,$gettok($v1,2-,47)),60,35) GoogleWeatherTB $nopath($v1) %OutputMethod 0
}
var %counter 2
while (%counter <= 5 && %OutputMethod == dialog) {
if ($bintween(&googleweather,src="//,",%counter)) {
var %icon $v1
GetGoogleWeatherIcon $gettok($v1,1,47) $replace($+(/,$gettok($v1,2-,47)),60,35) GoogleWeatherTB $nopath($v1) %OutputMethod %counter
did -ra GoogleWeather $calc(21 + %counter) $replace($regsubex($gettok($nopath(%icon),1,46),(.),$upper(\1)),_,$chr(32))
}
inc %counter
}
if ($bintween(&googleweather,display:inline">,</span>,1)) {
var %temp $remove($v1,f,c)
if (%OutputMethod == Window) {
drawtext -np @GoogleWeather 1 arial 14 30 4 $+($chr(2),%temp)
}
elseif (%OutputMethod == Dialog) did -ra GoogleWeather 34 %temp
}
if ($bintween(&googleweather,#666">,<,1)) {
var %conditions $v1
if (%OutputMethod == Dialog) {
did -ra GoogleWeather 31 %conditions
}
}
if ($bintween(&googleweather,#666">Wind:,</span>,1)) {
var %wind $httpstrip($v1)
if (%OutputMethod == Dialog) did -ra GoogleWeather 33 %wind
}
if ($bintween(&googleweather,#666">Humidity: ,</td>,1)) {
var %humidity $v1
if (%OutputMethod == Dialog) did -ra GoogleWeather 32 %humidity
elseif ($window(@GoogleWeather) && %OutputMethod == Window) {
UpdateToolBar -tp Location: %location $+(Humidity:,%humidity) $+(Wind:,%wind) Conditon: %conditions Temp: %temp
}
}
var %counter 2, %count 3
while (%counter <= 5 && %OutputMethod == dialog) {
if ($bintween(&googleweather,"display:inline">,°,%count)) {
did -ra GoogleWeather $calc(13 + %counter) $+(Low:,$v1)
}
inc %counter
inc %count 2
}
var %counter 2, %count 2
while (%counter <= 5 && %OutputMethod == dialog) {
if ($bintween(&googleweather,class="wob_t" style="display:inline">,°,%count)) {
var %v1 $v1
did -ra GoogleWeather $calc(17 + %counter) $+(High:,$gettok(%v1,$gettok(%v1,0,62),62))
}
inc %counter
inc %count 2
}
var %counter 1
while (%counter <= 9 && %OutputMethod == dialog) {
if (%counter < 5 && $bintween(&googleweather,top;text-align:center">,</td>,%counter)) {
did -ra GoogleWeather $calc(%counter + 6) $v1
}
inc %counter
}
}
}
}
alias -l httpstrip {
var %x, %i = $regsub($1-,/(^[^<]*>|<[^>]*>|<[^>]*$)/g,$null,%x), %x = $remove(%x, ,$chr(9),$chr(13))
return %x
}
alias -l fixit { $remove($1-,‎,$chr(13),|) }
alias -l bintween {
var %count = 1, %mark = 0, %mark2 = 0
while (%count <= $4) {
if ($bfind($1, %mark2, $2).text) {
%mark = $calc($bfind($1, %mark2, $2).text + $len($2))
if ($bfind($1, %mark, $3).text) {
%mark2 = $bfind($1, %mark, $3).text
}
else { return 0 }
}
else { return 0 }
inc %count
}
return $bvar($1, $iif(%mark > 0,%mark,1), $iif($calc(%mark2 - %mark) < 4130,$calc(%mark2 - %mark),4130)).text
}
Some random errors over time.
- /bwrite: unable to open file 'F:\Store\Programs\Internet\Chat\mIRC\MIRC - Bots\Back up\Windows Sp2 Files Before Format\ICO\Scripts\Script 3,31\ProIcons\GoogleWeatherTB\par
tly_cloudy.png' (line 60, script5.mrc)- /bwrite: unable to open file 'F:\Store\Programs\Internet\Chat\mIRC\MIRC - Bots\Back up\Windows Sp2 Files Before Format\ICO\Scripts\Script 3,31\ProIcons\GoogleWeatherTB\par
tly_cloudy.png' (line 60, script5.mrc)- /bwrite: unable to open file 'F:\Store\Programs\Internet\Chat\mIRC\MIRC - Bots\Back up\Windows Sp2 Files Before Format\ICO\Scripts\Script 3,31\ProIcons\GoogleWeatherTB\par
tly_cloudy.png' (line 60, script5.mrc)- /bwrite: unable to open file 'F:\Store\Programs\Internet\Chat\mIRC\MIRC - Bots\Back up\Windows Sp2 Files Before Format\ICO\Scripts\Script 3,31\ProIcons\GoogleWeatherTB\par
tly_cloudy.png' (line 60, script5.mrc)- /bwrite: unable to open file 'F:\Store\Programs\Internet\Chat\mIRC\MIRC - Bots\Back up\Windows Sp2 Files Before Format\ICO\Scripts\Script 3,31\ProIcons\GoogleWeatherTB\par
tly_cloudy.png' (line 60, script5.mrc)- /bwrite: unable to open file 'F:\Store\Programs\Internet\Chat\mIRC\MIRC - Bots\Back up\Windows Sp2 Files Before Format\ICO\Scripts\Script 3,31\ProIcons\GoogleWeatherTB\par
tly_cloudy.png' (line 60, script5.mrc)- /bwrite: unable to open file 'F:\Store\Programs\Internet\Chat\mIRC\MIRC - Bots\Back up\Windows Sp2 Files Before Format\ICO\Scripts\Script 3,31\ProIcons\GoogleWeatherTB\partly_cloudy
.png' (line 60, script5.mrc)- /bwrite: unable to open file 'F:\Store\Programs\Internet\Chat\mIRC\MIRC - Bots\Back up\Windows Sp2 Files Before Format\ICO\Scripts\Script 3,31\ProIcons\GoogleWeatherTB\par
tly_cloudy.png' (line 60, script5.mrc)- /bwrite: unable to open file 'F:\Store\Programs\Internet\Chat\mIRC\MIRC - Bots\Back up\Windows Sp2 Files Before Format\ICO\Scripts\Script 3,31\ProIcons\GoogleWeatherTB\par
tly_cloudy.png' (line 60, script5.mrc)- /bwrite: unable to open file 'F:\Store\Programs\Internet\Chat\mIRC\MIRC - Bots\Back up\Windows Sp2 Files Before Format\ICO\Scripts\Script 3,31\ProIcons\GoogleWeatherTB\par
tly_cloudy.png' (line 60, script5.mrc)- /bwrite: unable to open file 'F:\Store\Programs\Internet\Chat\mIRC\MIRC - Bots\Back up\Windows Sp2 Files Before Format\ICO\Scripts\Script 3,31\ProIcons\GoogleWeatherTB\par
tly_cloudy.png' (line 60, script5.mrc)- /bwrite: unable to open file 'F:\Store\Programs\Internet\Chat\mIRC\MIRC - Bots\Back up\Windows Sp2 Files Before Format\ICO\Scripts\Script 3,31\ProIcons\GoogleWeatherTB\par
tly_cloudy.png' (line 60, script5.mrc)- /bwrite: unable to open file 'F:\Store\Programs\Internet\Chat\mIRC\MIRC - Bots\Back up\Windows Sp2 Files Before Format\ICO\Scripts\Script 3,31\ProIcons\GoogleWeatherTB\partly_cloudy
.png' (line 60, script5.mrc)- /bwrite: unable to open file 'F:\Store\Programs\Internet\Chat\mIRC\MIRC - Bots\Back up\Windows Sp2 Files Before Format\ICO\Scripts\Script 3,31\ProIcons\GoogleWeatherTB\par
tly_cloudy.png' (line 60, script5.mrc)- /bwrite: unable to open file 'F:\Store\Programs\Internet\Chat\mIRC\MIRC - Bots\Back up\Windows Sp2 Files Before Format\ICO\Scripts\Script 3,31\ProIcons\GoogleWeatherTB\par
tly_cloudy.png' (line 60, script5.mrc)- /bwrite: unable to open file 'F:\Store\Programs\Internet\Chat\mIRC\MIRC - Bots\Back up\Windows Sp2 Files Before Format\ICO\Scripts\Script 3,31\ProIcons\GoogleWeatherTB\par
tly_cloudy.png' (line 60, script5.mrc)- /bwrite: unable to open file 'F:\Store\Programs\Internet\Chat\mIRC\MIRC - Bots\Back up\Windows Sp2 Files Before Format\ICO\Scripts\Script 3,31\ProIcons\GoogleWeatherTB\par
tly_cloudy.png' (line 60, script5.mrc)
My Dir Sucks i know^^ i've got 5 HDD's [3x 1 TB, 1x 2 TB, 1x 80GB SSD] and its a freaking mess. Can't even find a file:P forgot to mention that they are all full;p
@ProIcons Please try the updated code and let me know if you still have this issue.
Well its awsome but i kinda found a bug?
Well i'm not really sure if this bug is by your fault or by mine fault from some other code or whatever but my mIRC stop Responding, tried to Ctrl + Break but didn't work
That happend on a query of your script..
http://proicons.lostid.net/xasd.png
I also tried after this stuck to recreat the circumstances that lead to this hang, and i typed in the search area, the word $lasoz, again it hanged. Check it up..
Awesome script, I know this one is quite old, but I was wondering if you could add (or if someone posts a snippet to add) a feature where when you right click on one of the forecasts there is a "Post in active" popup. Just means if someone asks what the weather is like you don't have to copy it all down. Thanks for the script, great job!
it's easy to do this. You can use Dialog Editor to resize height [larger], then you can add how many buttons do you like. Then, u can search the code that display the wheater informations to something like this:
msg # Location: $2 $+(Humidity:,$3) $+(Wind:,$4) Conditon: $5 Temp: $6 [this is a easy example to understand the idea] :D
Check line 40 & 41 in 41 i think the /echo is wrong and in 40 the | character too.