The following is an Address Book plug-in script which will pull the weather forecast for a chosen contact from The Weather Underground. Open a new document in Script Editor, copy the text in the second part of this hint, and paste it in to the document. Save the script file in ~/Library -> Address Book Plug-Ins, and call this file anything you want.
[robg adds: This script works as described; control-click on the Address field to see the option in the pop-up menu.]
Enter into Script Editor:
(* This script adds a menu, over peoples address, when you select the menu,
it goes to the weather underground web site and displays the weather forcast
for the given address *)
using terms from application "Address Book"
on action property
return "address"
end action property
on action title for per with addr
set ccode to country code of addr
if ccode is missing value then
set ccode to default country code
end if
if ccode is equal to "us" then
return (("Weather Undergroud forecast at " as Unicode text) & ¬
name of per as Unicode text) & "'s " & label of addr
else
return ("Weather Underground forecast of " as Unicode text) & ¬
city of addr
end if
end action title
on should enable action for per with addr
if city of addr is missing value then
return false
end if
return true
end should enable action
on perform action for per with addr
set ccode to country code of addr
if ccode is missing value then
set ccode to default country code
end if
if ccode is equal to "us" then
set loc to ¬
"http://www.wunderground.com/cgi-bin/findweather/getForecast?query=" & ¬
zip of addr
else
set loc to ¬
"http://www.wunderground.com/cgi-bin/findweather/getForecast?query=" & ¬
city of addr & "," & country of addr
end if
tell application "Safari"
if (count of documents) is 0 then
make new document
end if
set URL of first document to loc
activate
end tell
return true
end perform action
end using terms from
Mac OS X Hints
http://hints.macworld.com/article.php?story=20040204135735343