Playing with AppleScript

Posted by – August 22, 2009

ApplesScript is a very interesting scripting language that allows the user to write scripts to automate computer tasks, it differs from the other script languages because of its syntax that is pretty closer to natural language.

I spent few hours this morning trying to understand how to write AppleScript scripts, It’s very simple, please read the AppleScript Language Guide to learn more about how to use AppleScript with your favorite applications.

The scripts below give to us an idea about how we can use AppleScript to change the behaviour of 4 most popular applications for MacOSX: iChat, Growl, Adium and Skype.

iChatStatus

1
2
3
tell application "iChat"
    set the status message to "New iChat status message"
end tell

iChatStatus can be used to change status message of the user on iChat. The first line starts with “tell” statement, we use this statement to specify the target of all commands on this script, in the second line we are using the “set” command to change a the value of “status message” property value on application to “New iChat status message”, the third line finishes the “tell” statement.


GrowlNotification

1
2
3
4
5
6
7
8
tell application "GrowlHelperApp"
    register as application ¬
        "Twist" all notifications {"Twist"} ¬
        default notifications {"Twist"} ¬
        icon of application "Script Editor"
   
    notify with name "Twist" title "Twist" description "Sending Growl notification" application name "Twist"
end tell

GrowlNotification is a little different from the others, in this script we are registering the application notifications with “register” command, you can use the “notify” command to execute growl notifications. You can find few examples about how to use AppleScript to generate Grow notifications here.

AdiumStatus

1
2
3
4
tell application "Adium"
    set the status type of every account to available
    set the status message of every account to "Changing status message of all accounts in Adium"
end tell

The AdiumStatus script allow us to change the status message of all IM accounts on Adium. You can perform many other tasks on Adium, a good documentation of all available AppleScript commands for Adium can be found here.

SkypeStatus

1
2
3
tell application "Skype"
    send command "SET PROFILE RICH_MOOD_TEXT Changing Skype status message" script name "Twist"
end tell

SkypeStatus shows how we can send commands to Skype, in this script we are changing the status message of skype profile, you can use AppleScript to execute many other commands on Skype, please refer to Skype API reference for more details.

Share

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>