10.7: Messages.app (BETA) uses iChat syntax for AppleScript

Feb 20, '12 07:30:00AM

Contributed by: mark hunte

When looking at the new Messages.app preferences I realised that you can get it to run applescripts on various events.

Under the Alerts Tab in the Messages.app preferences, you will find a list of Events under the drop down Menu 'Event.' Each event has its own set of independent options . All include a 'Run an AppleScript script' option. These scripts can just run on every instance of the chosen event.

But you can interact with the Messages.app with the script the same way you would in iChat.

So if I wanted to, for example, have my Mac send me a message, when an event occurs that matches certain criteria I can use the iChat syntax.

Example:

using terms from application "iChat"
  
  on message received theMessage from theBuddy for theChat
    --display dialog (theBuddy's name as string)
    if theMessage is "some Text" then
      -- do something
        send "some info" to theBuddy
    else
      
      -- do something
      send "some other info" to theBuddy
    end if
  end message received
  
end using terms from
Messages.app at the moment registers itself as iChat, not Messages. This most likely will change when the final release is out.

I did not use iChat that much. But I will be using Messages.app a lot. What makes this even better is I can send Messages to myself to get my Mac to do things.

[crarko adds: I'm sure in Mountain Lion there will be some interesting ways to combine Notifications with Messages, if the Sandbox permits it.]

Comments (4)


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