space
advocacy.gif
menu_top_inactive.gif space
Away and Back scripts
2007-01-03 20:26:33
Keywords: Adium,Colloquy,applescript,iChat, 726 hits

Away and Back scripts
I usually have Colloquy (IRC) and IM (Adium and/or iChat) running on my machine, and I've always wanted a convenient way to set me as away and back on all at once. This is a script that when run, asks for the reason why I'm away and then sets Adium, iChat and Colloquy away with that reason, if they're running.

  1. tell application "System Events"
  2.    set aApps to name of every application process
  3. end tell
  4. tell application "Finder"
  5.    activate
  6.    set utter to display dialog "Away reason" default answer "Gör något annat"
  7.    set theText to text returned of utter
  8. end tell
  9. if "Adium" is in aApps then
  10.    tell application "Adium"
  11.       set my status type to away
  12.       set my status message to theText
  13.    end tell
  14. end if
  15. if "iChat" is in aApps then
  16.    tell application "iChat"
  17.       set status to away
  18.       set status message to theText
  19.    end tell
  20. end if
  21. if "Colloquy" is in aApps then
  22.    tell application "Colloquy"
  23.       set aC to every connection
  24.       repeat with c in aC
  25.          set aR to (every chat room of c)
  26.          repeat with r in aR
  27.             send message "is away: " & theText to r with action tense
  28.             set away message of c to theText
  29.          end repeat
  30.       end repeat
  31.    end tell
  32. end if

/MAC/2007/01/03/20/Back.png
I use Finder for the display dialog part, since if I execute that within the "System Events" part, the dialog is unfocused. I obviously use Quicksilver to launch the script. cmd-space and then just "AW" which expands to Away. The script is saved as a script in my home Application folder, which Quicksilver is set to index.

And to set me back when I return, I run this script:
tell application "System Events" set aApps to name of every application process end tell if "Adium" is in aApps then tell application "Adium" set my status type to available set my status message to "" end tell end if if "iChat" is in aApps then tell application "iChat" set status to available set status message to "" end tell end if if "Colloquy" is in aApps then tell application "Colloquy" set aC to every connection repeat with c in aC set aR to (every chat room of c) repeat with r in aR send message "is back" to r with action tense set away message of c to "" end repeat end repeat end tell end if

Which pretty much does the same thing as the first, only the other way around. This one doesn't ask for a reason, though.

You are free to use the images in this blog as icons for the scripts (looks nicer in Quicksilver). Just click on each, which will magnify it in a new window, right-click on that and choose "copy image", and then paste it on the icon in the "get info" panel on each script.

Comments
0 comments
space space