Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ;Google ToolBar Weather by Ford_Lawnmower irc.GeekShed.net #Script-Help
- 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
- write googleweathertemp.txt $bvar(&googleweather,1-).text
- bread googleweathertemp.txt 1 $file(googleweathertemp.txt).size &googleweather
- var %OutputMethod $gettok($sock($sockname).mark,1,32)
- if ($bintween(&googleweather,obcontainer,Detailed forecast:,1)) {
- bset -t &googleweather 1 $remove($v1,‎)
- 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 class="r"><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,<img 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,<img 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,<td rowspan="2",</td>,1)) {
- var %temp $remove($gettok($v1,2,62),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">,<,2)) {
- var %wind $gettok($v1,2,58)
- if (%OutputMethod == Dialog) did -ra GoogleWeather 33 %wind
- }
- if ($bintween(&googleweather,#666">,<,3)) {
- var %humidity $gettok($v1,2,58)
- 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
- }
- }
- %counter = 4
- while (%counter <= 7 && %OutputMethod == dialog) {
- if ($bintween(&googleweather,#666">,<,%counter)) {
- did -ra GoogleWeather $calc(11 + %counter) $+(Low:,$v1)
- }
- inc %counter
- }
- %counter = 2
- while (%counter <= 9 && %OutputMethod == dialog) {
- if (%counter < 6 && $bintween(&googleweather,align:top">,<,%counter)) {
- did -ra GoogleWeather $calc(%counter + 5) $v1
- }
- if (%counter > 5 && $bintween(&googleweather,align:top">,<,%counter)) {
- did -ra GoogleWeather $calc(13 + %counter) $+(High:,$v1)
- }
- inc %counter
- }
- }
- }
- }
- 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
- }
Add Comment
Please, Sign In to add comment