Skip to content

Textexpander: Snippet to get tomorrow’s weather forecast via AppleScript

Just downloaded TextExpander yesterday and coming up with new ways to make it useful.  I travel often and always wanting to know what the weather is going to be like in my next destination, so I made the snippet "getweather" that is the AppleScript code below to prompt me for what zip code I will be in, then load that location's weather forecast for tomorrow in Google Chrome.


tell application "TextExpander" to activate
display dialog "What zip code?" default answer ""
set zip to (text returned of result)

tell application "Google Chrome"
	set theUrl to "" & zip

	if (count every window) = 0 then
		make new window
	end if

	set found to false
	set theTabIndex to -1
	repeat with theWindow in every window
		set theTabIndex to 0
		repeat with theTab in every tab of theWindow
			set theTabIndex to theTabIndex + 1
			if theTab's URL = theUrl then
				set found to true
			end if
		end repeat

		if found then
			exit repeat
		end if
	end repeat

	if found then
		tell theTab to reload
		set theWindow's active tab index to theTabIndex
		set index of theWindow to 1
		tell window 1 to make new tab with properties {URL:theUrl}
	end if
end tell
Find this useful? Take just a moment and give a $1. Thanks!
Digg This
Reddit This
Stumble Now!
Buzz This
Vote on DZone
Share on Facebook
Bookmark this on Delicious
Kick It on
Shout it
Share on LinkedIn
Bookmark this on Technorati
Post on Twitter
Google Buzz (aka. Google Reader)