some time ago an idea came to my mind: creating a little AS which does the follow:
checking, whether skype/adium/mail is online
if yes:
setting Adium to a custom away status, where growl and sounds are deactivated
setting skype to busy
deactivating my mail-accounts
if no:
1a) setting Adium to online
2a) setting skype to online
3a) activating my mail-accounts
What did I find up to now?
A) how to switch the skype status:
tell application "Skype"
send command "SET USERSTATUS DND/ONLINE" script name "AppleScript status setter"
end tell
B) setting Mail-account on-/offline:
tell application "Mail"
set enabled of account "Test" to true/false
end tell
C) setting adium to online:
tell application "Adium"
go available
end tell
What’s stlll missing is, how to change the adium status to a user-defined, let’s called it for creativity’s sake “test”. I opened the AS-Library for adium. There is the followng entry:
I just don’t know how to use that help and create a line which sets my status to “test”.
And the final thing is to check the current status.
The final aim is to get one script to which I asign a shortcut using spark which sets my mac to a mode where I’m not disturbed by anything.
Any help is HUGELY appreciated!!! I know, that it’s probably something VERY simple to write, but I’m just not enough into AS @ the moment.
Every account has a status property which can be set to a status. An account is a property of an application. So the script must look like this.
tell application "Adium" to set status of (some account) to (some status)
A one-liner which asks the user for the account and status could look like this:
tell application "Adium" to set status of account ¬
((choose from list (get name of every account)) as string) to ¬
(some status whose title is (((choose from list (title of every status) as list)) as string))
you have to setup customname, since it’s a variable:
set customName to "Your Name Here" -- a string assigned to a variable
tell application "Adium" to tell account 1 to set its status to (some status whose title is customName)
now I get the reply that the given object is a property, not an element.
What would you guess? Maybe it’s easier trying to change the default “go away”-setting? I just can’t find the right switch to do that. I went through the pref-files and the App-Support-folder, but I can’t find the right setting?
You can’t make new commands, so the "go " & yourStatus will never work.
But it seems that
set customName to "Afwezig" -- a string assigned to a variable (here Away)
tell application "Adium" to set status of account 1 to (some status whose title is customName)
is working.
But you have to make sure the given status exists, else Adium crashes
I have no idea what the error might be. But the code below works well on my Mac (10.5). Even when I’m offline the script changes the status, of course with a slight delay. I’ve set up the custom account via the application preferences (http://developerief2.site11.com/Public-Files/Adium_Custom_Status.png).
Script that works,
tell application "Adium" to set allAccounts to name of every account
set myAccount to choose from list allAccounts
set myAccount to myAccount as string
tell application "Adium" to set status of account result to (some status whose title is "Test")
If it still does not work,
maybe you should share the code that throws the error?
tell application "Adium" to set status of every account to (some status whose title is "Test")
THANKS!!!
The last issue would be to insert the if-condition:
it should something like:
if status of Adium is "online" then
tell application "Skype"
send command "SET USERSTATUS DND" script name "AppleScript status setter"
end tell
tell application "Mail"
set enabled of account "Test" to false
end tell
tell application "Adium" to set status of every account to (some status whose title is "Test")
else
tell application "Skype"
send command "SET USERSTATUS ONLINE" script name "AppleScript status setter"
end tell
tell application "Mail"
set enabled of account "Test" to true
end tell
tell application "Adium" to set status of every account to (some status whose title is "online")
I just don’t know the AS-syntay, up to now I was just programming in MatLab
if adiumStatuses() contains "Online" then
tell application "Skype" to send command "SET USERSTATUS DND" script name "AppleScript status setter" -- skype
tell application "Mail" to set enabled of account "Test" to false -- mail
tell application "Adium" to set status of every account to (some status whose title is "Test") -- adium
else
tell application "Skype" to send command "SET USERSTATUS ONLINE" script name "AppleScript status setter" -- skype
tell application "Mail" to set enabled of account "Test" to true -- mail
tell application "Adium" to set status of every account to (some status whose title is "Online") -- adium
end if
(* ===== HANDLERS ===== *)
on adiumStatuses()
tell application "Adium" to return (title of status of every account)
end adiumStatuses
I had to change it slightly, due to german Names: Available (NOT online, I was mistaken) turns to Anwesend.
After that everything started working properly.
THANKS VERY MUCH!!!
As to the learning of AS: I already bought the missing manual of AS, my only trouble is time. Studying, jobs keep me busy most of the time, some of the remaing goes into studying and working with the server OS. But oneday there will be time …
Thanks again, now my lovely whity is a step closer to perfection!!!