Index syndication
comment syndication

IM Status Applescript for iChat Adium and Skype

December 19, 2008 at 12:04 · Filed under mac

I use iChat, Adium and Skype all at the same time. I was looking for a quick way to change the status of all three of them with one fell swoop.

Looking at what other people had written I came across a good example at Jason Kenison’s blog. He had implemented a method whereby you select Away or Available and then the script will change the status of all three. It worked for Skype and iChat but not for Adium.

The method of setting the status as Jason had done no longer works under Adium 1.3+ and to that end someone had raised a support ticket with the Adium team. The details in the ticket and some further googling led me to the Adium Applescript interface documentation. The means of setting the status now is as simple as
tell application "Adium" to go away
This solved the problem with Adium.

But of course I was not happy with that. If you only had two of the programs running, and did not want the third running e.g. Skype, the script would launch the application to set the status. This is where Apples Language guide did the trick. One can check to see if a process is running like this
ell application "System Events" to set SkypeIsRunning to (count of (every process whose name is "Skype")) > 0
The variable SkypeIsRunning could be used as a true/false variable for logical testing.

Still not satisfied, I wondered if there was a way to set the “Status Text” for the applications, say if I was in a meeting. I knew how to do this for iChat and Adium but what about Skype? The developers documentation shows how this can be achieved and then it was as simple as setting that status text like this for all three applications

 tell application "Adium" to go away with message "In Meeting"

tell application "iChat"
set status message to "In Meeting"
end tell

tell application "Skype"
send command "SET PROFILE MOOD_TEXT In Meeting" script name "IMStatus"
end tell

So now I have a way to quickly tell the application to be Available, Away or In a Meeting.

Here is the final script with all the included ideas.

 -- IMStatus
-- version 1.0, Lantrix (https://techdebug.com)
-- idea conceived from script by Jason Kenison "theWebGuy" Blog at:
-- http://www.jasonkenison.com/blog.html?id=22

(*
Copyright (c) 2008, TechDebug.com

Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.

THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*)

-- Display Dialog
set imState to display dialog "For Skype/iChat/Adium choose" buttons {"Available", "Away", "Meeting"} default button 1

--Check App Status, to only act on apps if running
tell application "System Events" to set AdiumIsRunning to (count of (every process whose name is "Adium")) > 0
tell application "System Events" to set iChatIsRunning to (count of (every process whose name is "iChat")) > 0
tell application "System Events" to set SkypeIsRunning to (count of (every process whose name is "Skype")) > 0

-- Meeting
if the button returned of imState is "Meeting" then
-- Adium (works with 1.2+ as per http://trac.adiumx.com/wiki/AppleScript_Support_1.2 documentation)
if AdiumIsRunning then
tell application "Adium" to go away with message "In Meeting"
end if
-- iChat
if iChatIsRunning then
tell application "iChat"
set status to away
set status message to "In Meeting"
end tell
end if
-- Skype
if SkypeIsRunning then
tell application "Skype"
send command "SET USERSTATUS DND" script name "IMStatus"
send command "SET PROFILE MOOD_TEXT In Meeting" script name "IMStatus"
end tell
end if
end if

-- Away
if the button returned of imState is "Away" then
-- Adium (works with 1.2+ as per http://trac.adiumx.com/wiki/AppleScript_Support_1.2 documentation)
if AdiumIsRunning then
tell application "Adium" to go away
end if
-- iChat
if iChatIsRunning then
tell application "iChat"
set status to away
end tell
end if
-- Skype
if SkypeIsRunning then
tell application "Skype"
send command "SET USERSTATUS AWAY" script name "My Script"
end tell
end if
end if

-- Available
if the button returned of imState is "Available" then
-- Adium (works with 1.2+ as per http://trac.adiumx.com/wiki/AppleScript_Support_1.2 documentation)
if AdiumIsRunning then
tell application "Adium" to go available
end if
-- iChat
if iChatIsRunning then
tell application "iChat"
set status to available
set status message to ""
end tell
end if
-- Skype
if SkypeIsRunning then
tell application "Skype"
send command "SET USERSTATUS ONLINE" script name "My Script"
send command "SET PROFILE MOOD_TEXT" script name "IMStatus"
end tell
end if
end if

You can download the script and try it for yourself.

Running this AppleScript will pop up a dialog box that gives you 3 options. You can customise the "In Meeting" to your own status. Have fun.

Leave a Comment