An AppleScript to look up phone numbers in Google

May 28, '03 10:05:00AM

Contributed by: macubergeek

Well just bought Google Hacks and couldn't resist. Had to try at least one! Here's an AppleScript to look up phone numbers using Google:

tell application "Finder"
  try
    display dialog "enter full first name lowercase" default answer ¬
      "joe" buttons {"OK"} default button 1
    set first_name to text returned of the result
    display dialog "enter last name lower case" default answer ¬
      "blow" buttons {"OK"} default button 1
    set last_name to text returned of the result
    set full_name to first_name & " " & last_name
    -- The next three lines should be entereed as ONE LINE:
    display dialog ¬
      "Enter city in lower case, leave blank if you don't know it."
      default answer "my city" buttons {"OK"} default button 1
    set my_city to text returned of the result
    display dialog "Enter state as two letter abbreviation" default answer ¬
      "ca" buttons {"OK"} default button 1
    set my_state to text returned of the result
    tell application "Safari"
    -- The next two lines should be entereed as ONE LINE:
      open location "http://www.google.com/search?q=rphonebook:" & 
        first_name & " " & last_name & " " & my_city & " " & my_state
    end tell
  end try
end tell
Be careful of line wraps on the display dialog lines and the open location line at the end. Be sure to copy and paste into Script Editor and make them all one line. Save this AppleScript as a compiled script and put it in your scripts folder. From there, you can access it using Script menu in the menubar.

Comments (7)


Mac OS X Hints
http://hints.macworld.com/article.php?story=20030525131844501