Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!


Click here to return to the 'UPDATED Feb 2012: Add a zip code lookup to Address Book ' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
UPDATED Feb 2012: Add a zip code lookup to Address Book
Authored by: dschargel on Feb 14, '12 12:07:55PM
Once again the USPS changed their website code, so here is the script again (building upon the previous hints) with the updated URL. Two versions: one to open with Safari and the second to open with Chrome.

Safari version…

-- zip code locator
using terms from application "Address Book"
	on action property
		return "address"
	end action property
	
	on action title for p with e
		if zip of e contains "-" then
			return "Zip Code Present"
		else
			return "ZIP + 4 Lookup "
		end if
	end action title
	
	on should enable action for p with e
		if zip of e does not contain "-" then
			return true
		else
			return false
		end if
	end should enable action
	
	on perform action for p with e
		set LookupURL to ¬
			"https://tools.usps.com/go/ZipLookupResultsAction!input.action?resultMode=0&companyName=&address1=" & street of e & "&address2=&city=" & ¬
			city of e & "&state=" & state of e & "&&urbanCode=&postalCode=&zip="
		tell application "Safari" to open location LookupURL
		return true
	end perform action
end using terms from

Chrome version…

-- zip code locator
using terms from application "Address Book"
	on action property
		return "address"
	end action property
	
	on action title for p with e
		if zip of e contains "-" then
			return "Zip Code Present"
		else
			return "ZIP + 4 Lookup "
		end if
	end action title
	
	on should enable action for p with e
		if zip of e does not contain "-" then
			return true
		else
			return false
		end if
	end should enable action
	
	on perform action for p with e
		set LookupURL to ¬
			"https://tools.usps.com/go/ZipLookupResultsAction!input.action?resultMode=0&companyName=&address1=" & street of e & "&address2=&city=" & ¬
			city of e & "&state=" & state of e & "&&urbanCode=&postalCode=&zip="
			tell application "Google Chrome"
				if not (exists first window) then
					make new window
					set URL of last tab of first window to LookupURL
				else
					tell first window
						set newTab to make new tab with properties {URL:LookupURL}
					end tell
				end if
				activate
			end tell
		return true
	end perform action
end using terms from


- David

[ Reply to This | # ]
UPDATED Feb 2012: Add a zip code lookup to Address Book
Authored by: odinsdad on Mar 08, '12 11:14:17AM

Awesome! I just updated this and it works great once again. It would be nice for it to just go fetch the Zip+4 and amend it automatically to the address book entry that the query came from instead of having to click edit, and type in the newly looked up zip+4 then click done.

Either way, beggars can't be choosers and thanks for getting this script updated so quickly.

~e

By the way, here is how to install the script instead of having people go find the original post...:

To install on your computer:
Copy the script above, between the dotted lines
Open /Applications -> AppleScript -> Script Editor.app
Paste the script into the top of a new script window
Save the script using these settings: Save As: ZipCodeLocator, Where: ~/Library -> Address Book Plug-Ins/; File Format: Script; Options: [x] Run only

Additional note:
If your on (OSX 10.7.x) Lion and can't find your Library folder because it's hidden by default go to the Finder -> Go -> Go to Folder...
type in ~/Library/ in the box and your home folder Library folder will open up for you...



[ Reply to This | # ]