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 {
- ;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
- writeini GoogleWeatherTB.ini Settings Location %MyLocation
- if ($exists($qt($mircdirGoogleWeatherTB/tbwin.dll))) {
- if (!$readini(GoogleWeatherTB.ini,Settings,Left)) writeini GoogleWeatherTb.ini Settings Left 535
- if (!$readini(GoogleWeatherTB.ini,Settings,Size)) writeini GoogleWeatherTb.ini Settings Size 50
- window -ahBfp +d @GoogleWeather $readini(GoogleWeatherTB.ini,Settings,Left) 0 $readini(GoogleWeatherTB.ini,Settings,Size) 31
- drawfill -r @GoogleWeather $rgb(240,240,230) $rgb(240,240,240) 0 0
- dll $tbwin Attach @GoogleWeather
- dll $tbwin Select @GoogleWeather
- dll $tbwin OnMouse dclick /dGetGoogleWeather
- dll $tbwin OnMouse sclick /GoogleWeatherMove
- window -ar @GoogleWeather
- GetGoogleWeather Window 0 %MyLocation
- .timerGoogleWeatherTB -o 0 100 GetGoogleWeather Window 0 %MyLocation
- }
- else Gettbwin.dll
- }
- alias -l tbwin return $qt($mircdirGoogleWeatherTB/tbwin.dll)
- alias dGetGoogleWeather {
- if ($tbmouse(key) == 1) GetGoogleWeather Dialog 0 $readini(GoogleWeatherTB.ini,Settings,Location)
- else {
- var %Left $calc($readini(GoogleWeatherTB.ini,Settings,Left) $iif($tbmouse(key) == 3,-,+) 10)
- writeini GoogleWeatherTB.ini Settings Left %Left
- window -r @GoogleWeather %Left 0 $readini(GoogleWeatherTB.ini,Settings,Size) 31
- }
- }
- alias GoogleWeatherMove {
- if ($tbmouse(key) != 1) {
- var %Left $calc($readini(GoogleWeatherTB.ini,Settings,Left) $iif($tbmouse(key) == 3,-,+) 1)
- writeini GoogleWeatherTB.ini Settings Left %Left
- window -r @GoogleWeather %Left 0 $readini(GoogleWeatherTB.ini,Settings,Size) 31
- }
- }
- alias tbmouse {
- var %x = $dll($tbwin, GetMouse, NOT_USED)
- var %z = x y key hover win
- if ($findtok(%z, $1, 1, 32)) return $gettok(%x, $ifmatch, 32)
- else return $null
- }
- on *:Start: {
- if ($readini(GoogleWeatherTB.ini,Settings,Status) != Off) GweatherTBInit
- }
- alias -l GetGoogleWeather {
- .sockclose QQG.o.o.gleWeatherTB
- sockopen QQG.o.o.gleWeatherTB www.google.com 80
- sockmark QQG.o.o.gleWeatherTB $1 $+(/ig/api?weather=,$urlencode($3-)) $2
- }
- On *:sockopen:QQG.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:QQG.o.o.gleWeatherTB: {
- if ($sockerr) { sockclose $sockname | return }
- else {
- var %GoogleWeather | sockread %GoogleWeather
- echo -gat - %GoogleWeather
- var %OutputMethod $gettok($sock($sockname).mark,1,32)
- if (<problem_cause data=""/> isin %GoogleWeather && %OutputMethod == Dialog) {
- did -ra GoogleWeather 2 $did(GoogleWeather,28) :: No Data found for $did(GoogleWeather,28)
- }
- if ($regex(%GoogleWeather,/<city data="(.*?)"\/>/i) && %OutputMethod == Dialog) {
- dialog $iif($dialog(GoogleWeather),-v,-m GoogleWeather) GoogleWeather
- did -ra GoogleWeather 2 $regml(1) on $fulldate
- }
- if ($regex(%GoogleWeather,/<humidity data="[^:]*:(.*?)"\/>/i) && %OutputMethod == Dialog) {
- did -ra GoogleWeather 32 $regml(1)
- }
- if ($regex(%GoogleWeather,/<wind_condition data="[^:]*:(.*?)"\/>/i) && %OutputMethod == Dialog) {
- did -ra GoogleWeather 33 $regml(1)
- }
- if ($regex(%GoogleWeather,/<day_of_week data="(.*?)"\/>/gi) && %OutputMethod == Dialog) {
- var %count 1
- while (%count <= $regml(0)) {
- did -ra GoogleWeather $calc(%count + 6) $regml(%count)
- inc %count
- }
- }
- if ($regex(%GoogleWeather,/<low data="(.*?)"\/>/gi) && %OutputMethod == Dialog) {
- var %count 1
- while (%count <= $regml(0)) {
- did -ra GoogleWeather $calc(%count + 14) $+(Low:,$regml(%count))
- inc %count
- }
- }
- if ($regex(%GoogleWeather,/<high data="(.*?)"\/>/gi) && %OutputMethod == Dialog) {
- var %count 1
- while (%count <= $regml(0)) {
- did -ra GoogleWeather $calc(%count + 18) $+(High:,$regml(%count))
- inc %count
- }
- }
- if ($regex(%GoogleWeather,/<condition data="(.*?)"\/>/gi)) {
- if (%OutputMethod == Window) {
- clear @GoogleWeather
- writeini GoogleWeatherTB.ini Settings Size $calc(42 + ($len($regml(1)) * 8))
- window -r @GoogleWeather $readini(GoogleWeatherTB.ini,Settings,Left) 0 $calc(42 + ($len($regml(1)) * 8)) 31
- drawfill -r @GoogleWeather $rgb(240,240,230) $rgb(240,240,240) 0 0
- drawtext -np @GoogleWeather 1 arial 12 42 0 $+($chr(2),$regml(1))
- }
- elseif (%OutputMethod == Dialog) {
- did -ra GoogleWeather 31 $regml(1)
- var %count 2
- while (%count <= $regml(0)) {
- did -ra GoogleWeather $calc(21 + %count) $regml(%count)
- inc %count
- }
- }
- }
- if ($regex(%GoogleWeather,/<temp_f\sdata="(.*?)"\/>/)) {
- if (%OutputMethod == Window) {
- drawtext -np @GoogleWeather 1 arial 12 42 13 $+($chr(2),$regml(1),$chr(186))
- }
- elseif (%OutputMethod == Dialog) did -ra GoogleWeather 34 $+($regml(1),$chr(186))
- }
- if ($regex(%GoogleWeather,/<icon data="/ig/images/weather/(.*?)"\/>/gi)) {
- GetGoogleWeatherIcon www.google.com $+(/ig/images/weather/,$regml(1)) GoogleWeatherTB $regml(1) %OutputMethod 0
- drawdot @GoogleWeather
- if (%OutputMethod == Dialog) {
- var %c 2
- while (%c <= $regml(0)) {
- GetGoogleWeatherIcon www.google.com $+(/ig/images/weather/,$regml(%c)) GoogleWeatherTB $regml(%c) %OutputMethod %c
- inc %c
- }
- }
- }
- }
- }
- alias -l GetGoogleWeatherIcon {
- if ($isfile($qt($+($3,\,$4)))) {
- if ($5 == Window) drawpic -ns @GoogleWeather 0 0 35 30 $+(GoogleWeatherTB/,$4)
- elseif (($5 == Dialog)) did -g GoogleWeather $iif($6,$calc($6 + 9),3) $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 35 30 $qt($+($3,/,$4))
- }
- elseif ($5 == Dialog) {
- if (!$6) did -g GoogleWeather 3 $qt($+($3,/,$4))
- else did -g GoogleWeather $calc(9 + $6) $qt($+($3,/,$4))
- }
- }
- }
- alias -l Gettbwin.dll {
- ;Downloads tbwin.dll v0.3 by dohcan
- ;http://www.mircscripts.org/comments.php?cid=1206
- echo -gat Downloading docking dll. Please wait.....
- if ($isfile($qt(GoogleWeatherTB/tbwin.dll))) .remove $qt(GoogleWeatherTB/tbwin.dll)
- if (!$isdir($qt(GoogleWeatherTB))) mkdir $qt(GoogleWeatherTB)
- sockopen Gettbwin.dll fordlawnmower.googlecode.com 80
- sockmark Gettbwin.dll fordlawnmower.googlecode.com /files/tbwin.dll GoogleWeatherTB tbwin.dll
- }
- On *:sockopen:Gettbwin.dll:{
- 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:Gettbwin.dll:{
- if (!$gettok($sock($sockname).mark,5,32)) {
- var %Gettbwin.dll | sockread %Gettbwin.dll
- if (!%Gettbwin.dll) { sockmark $sockname $addtok($sock($sockname).mark,1,32) }
- }
- else {
- sockread &Gettbwin.dll
- bwrite -s $qt($+($gettok($sock($sockname).mark,3,32),\,$gettok($sock($sockname).mark,4,32))) -1 -1 &Gettbwin.dll
- }
- }
- On *:sockclose:Gettbwin.dll:{
- tokenize 32 $sock($sockname).mark
- if ($exists($qt($+($3,/,$4)))) {
- echo -gat Download complete.
- GweatherTBInit
- }
- else echo -gat Error downloading tbwin.dll
- }
- alias -l urlencode return $replace($regsubex($1-,/([^a-z0-9\s])/ig,% $+ $base($asc(\t),10,16,2)),$chr(32),+)
- menu channel,status,menubar,@GoogleWeather {
- -
- Google Weather
- .$iif($timer(GoogleWeatherTB),$style(3)) On:{
- writeini GoogleWeatherTB.ini Settings Status On
- GweatherTBInit
- }
- .$iif(!$timer(GoogleWeatherTB),$style(3)) Off:{
- .timerGoogleWeatherTB off
- window -c @GoogleWeather
- writeini 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
- }
Add Comment
Please, Sign In to add comment