Open an iChat SMS window from LaunchBar

Mar 26, '09 07:30:00AM

Contributed by: Anonymous

LaunchBar has a convenient Skype dialer script, based on this hint from a few years ago, which takes a phone number and dials it in Skype. The following script takes a phone number and creates a chat window in iChat for SMS use. It only works for US numbers. Some of the code was taken from an AppleScript elsewhere on macosxhints.com.

Here's the code:

property lb_prefix : "tel:"

on handle_string(s)
  -- Trim the LaunchBar prefix if it exists.
  if s starts with lb_prefix then set s to ¬
    (text ((count lb_prefix) + 1) thru -1 of s)
  
  -- Strip non-numeric characters.
  set numeric to ""
  repeat with i from 1 to the number of characters in s
    if character i of s is in {"+", "0", "1", "2", "3", "4", "5", "6", "7", "8", "9"} then set numeric to numeric & character i of s
  end repeat
  set s to "+1" & numeric
  
  -- Service 1 is always AIM apparently.
  tell application "iChat"
    send "" to buddy s of service 1
    activate
  end tell
end handle_string
[robg adds: I haven't tested this one.]

Comments (0)


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