This really isn't any more than some combinations of hints. It allows one to select a network location. Based on that selection, it sets the network location and then sets an iChat screen name the user wants to use that location. That is, if one selects "work," the script sets the location to "work" and then sets the screen name to your predefined "work" screen name. At the end of the script, I have it launch iChat and Mail and then hide them both. To use this script, one must have the following set up:
Enter this in Script Editor:
-- user must edit this...any number of locations is possible
-- locations MUST correspond with screennames
set myLocations to {"Location#1", "Location#2", "Location#3"}
set myScreennames to {"screenname1", "screenname2", "screenname3"}
tell application "Finder"
set loc to (choose from list myLocations with prompt ¬
"Select your location:" without multiple selections allowed) as string
if loc is "false" then return
repeat with i from 1 to (count of myLocations)
if loc is item i of myLocations then
set nom to quoted form of (item i of myScreennames)
exit repeat
end if
end repeat
end tell
try
-- note that there MUST be a carriage return
-- BEFORE the "defaults" line
(do shell script ¬
"scselect " & loc & "
defaults write com.apple.iChat.AIM LoginAs " & nom)
tell application "iChat"
launch
end tell
tell application "Mail"
launch
end tell
tell application "System Events"
if exists application process "iChat" then
set visible of application process "iChat" to false
end if
if exists application process "Mail" then
set visible of application process "Mail" to false
end if
end tell
end try
[robg adds: I haven't tested this one myself, but an AppleScript guru friend of mine did -- he tweaked a couple of things, and pronounced it functional.]
Mac OS X Hints
http://hints.macworld.com/article.php?story=20040508201816653