ONE script for setting my mac to faaaar away :-)

Hi to everyone!!!

some time ago an idea came to my mind: creating a little AS which does the follow:

  1. checking, whether skype/adium/mail is online

if yes:

  1. setting Adium to a custom away status, where growl and sounds are deactivated
  2. setting skype to busy
  3. 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.

All the best

joh

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))

Hope it helps,
ief2

Hey!!!

thanks for the reply!!!

I just gave it a try, but when try to change the status to “customname” I just get an error message: "The variable customname is not defined.

I would change simply to “go away”, but it doesnt disble growl and sound effects which is exactly what I need.

Any idea how to get this problem out of the way?

All the best

joh

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)

Hope it helps,
ief2

Hmmm…

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?

All the best

joh

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

Hope it works,
ief2

Hmmmm…

Weird: if I’m on “online”, I geht the error message:

adium received an error: the … (failed to translate that :-)) container contained an empty list.

BUT: when I’m in the “customname” status, the script works BUT creates another status “customname”.

System: 10.6.2.

Any idea what that might be?

All thebest and THANKS for your help and patience!!!

joh

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?

Hope it works,
ief2

NOW it’s done:

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 :frowning:

All the best

joh

Do you mean something like this?

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

Hope it helps,
ief2

PS: If you really want to learn AppleScript, I recommend you to take a look at the tutorials here at MacScripter:
http://macscripter.net/viewtopic.php?id=25631

WORKS!!!

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 … :slight_smile:

Thanks again, now my lovely whity is a step closer to perfection!!!

All the best

joh