Page 1 of 1
Documentation on AppleScript changes?
Posted: Sun Jan 06, 2008 7:15 pm
by mtimmsj
Before I declare the AppleScript support in 1.2 completely broken and start filing trac's, is there any documentation available on how to use the new AppleScript support? Something like the following no longer works:
Code: Select all
tell application "Adium"
get UID of the contact of the active chat of the first interface controller
end tell
In fact the AppleScript dictionary for Adium no longer shows UID as a property of contact but this tell block compiles just fine. It also shows service as a property of the account class but it isn't.
This crashes Adium:
Code: Select all
tell application "Adium"
get every window
end tell
However, this works:
Code: Select all
tell application "Adium"
get name of every window
end tell
I found #8734 which points to
http://trac.adiumx.com/wiki/AppleScript, but that wiki entry has virtually no information on it.
Other examples of things that I thought would work but don't:
Code: Select all
tell application "Adium"
get every contact
end tell
Code: Select all
tell application "Adium"
get every account
end tell
Code: Select all
tell application "Adium"
get every status
end tell
Posted: Sun Jan 06, 2008 8:57 pm
by mtimmsj
I had script editor up and running during my upgrade. After restarting script editor, things seem to be working properly now.
Posted: Sun Jan 06, 2008 9:07 pm
by Catfish_Man
Good to hear. I was a little worried when I started reading this.
Posted: Mon Jan 07, 2008 12:21 am
by evands
mtimmsj wrote:I had script editor up and running during my upgrade. After restarting script editor, things seem to be working properly now.
Right. Script editor caches the script dictionary of each application it accesses; it doesn't recheck the dictionary while it's running. It was trying to use all the old version's dictionary with the new Adium, which obviously works poorly if at all

Posted: Mon Jan 07, 2008 12:42 am
by salle77
mtimmsj wrote:I had script editor up and running during my upgrade. After restarting script editor, things seem to be working properly now.
Thanks! That was the problem for me to.
mtimmsj wrote:
This crashes Adium:
Code: Select all
tell application "Adium"
get every window
end tell
That however crashes for me to (after restart of script editor and adium).
Posted: Mon Jan 07, 2008 8:00 am
by mtimmsj
Yeah I've found a couple of other crashes as well. For example this causes a crash:
Code: Select all
tell application "Adium"
get properties of active chat
end tell
In addition, while this new applescript support seems to support some new functionality and improve things significantly, it also removes a fair amount of functionality. For example we can no longer get or set contact images via applescript because the image is no longer a property of the contact class. This effectively kills (at least until this property is restored) a project I've been maintaining for other people where I work that retrieved contact images for Sametime contacts from a remote server and programatically assigned them to the contact. Maybe I can do something with Address Book to workaround this. I'm not sure how the Address Book integration works though or if it would work with Sametime contacts as there is no Sametime option in the AIM field for a person in address book .
Posted: Mon Jan 07, 2008 7:14 pm
by evands
Please submit Trac tickets with specific problems with the new Applescript dictionary (one issue per ticket, please). Removing the contact image properties, for example, is certainly a regression which should be fixed - definitely file that one and any others you come across.
Adium is an evolving program; sometimes you have to take a step backward to take a leap forward.
Posted: Mon Jan 07, 2008 11:55 pm
by mtimmsj
Ok I've opened the one for image access via Applescript #8818.
However, I'm not entirely sure that all of the issues I have run into are not expected. It'd be nice if there was some documentation (besides the dictionary) that explains how to do some things with the new AppleScript support.
One example where I'm not sure if the issue is a bug, is the use of "name" in the AppleScript dictionary. Many classes have a "name" property but if you try to write a script that accesses these properties, when you compile the script "name" seems to always be converted to "title". For example:
Code: Select all
tell application "Adium" to get name of service of every account
Becomes:
Code: Select all
tell application "Adium" to get title of service of every account
If you don't mind the noise of extra trac's for things that might not be bugs I'll be happy to file them.
Posted: Tue Jan 08, 2008 2:06 am
by mtimmsj
After thinking my question over some more I figured it would be more productive if I just submitted the trac's. So here are the ones I have submitted so far:
#8818
#8821
#8823
#8824
#8825
Posted: Tue Jan 08, 2008 6:28 am
by Catfish_Man
awesome. Thanks

Posted: Tue Jan 08, 2008 7:24 am
by mtimmsj
FYI: #8818 was marked invalid but I think it was a misunderstanding. I've posted a response but I don't think I have permission to re-open it (at least I can't see any such option when I view it). Should I open another one, or can one of the dev's re-open that one?
Posted: Wed Jan 09, 2008 1:16 am
by mtimmsj
Ok trying to bring this thread back on topic.
Since my original request was for documentation and none of the responses seemed to address this request specifically, I went ahead and created my own documentation for Adium 1.2 AppleScript support. It's rather lengthy has mostly simplistic examples and is probably incomplete but it seems better than nothing. How would I go about posting it to the wiki? Seems like my userid (mtimmsj) doesn't have permissions to create a new document or modify documents on the wiki. I could post it in the forum but it seems like it might be too long of post (Textmate says it's 338 lines long and most lines are longer than 80 characters).
Here is the things it covers:
- Working with the application
- Working with accounts
- Working with contacts
- Working with services
- Working with windows
- Working with chat windows
- Working with chats
- Working with statuses
- Other commands (like make, delete, exists, count, etc)
Here are some things that I'd like to add to it:
- Creating an AdiumScript bundle
- Expand on the make new sytax and provide better examples. All my attempts to create a functional example failed. The closest I got was creating a status, the status is created but I still get an error.
- Figure out a way to utilize the move command
And an excerpt from the part about working with the application class:
The application class has one interesting property - 'active chat'. You can use it to access the active chat. We'll see what this means later when we talk about working with chat objects. However, for now just be aware that you can do the following:
Code: Select all
tell application "Adium" to send active chat message "Hello World!"
Side note: Those of us with devious minds (you know who you are!) may look at the previous example and think, "Hmm... what if I wrapped this in a loop and sent the same thing repeatedly to the active chat? Can you say IM bomb?" If you do it, please do it with some class (maybe use Chuck Norris facts) and apologize afterwards. :-)
The application class also responds to some messages that you might not expect. Those messages are "go online", "go available", "go offline", "go away" and "go invisible" which are all an easy way to set your global status or to get all accounts to go online or offline. Here's an example:
Code: Select all
tell application "Adium" to go online
If you want more granular settings for things like a specific status for a specific account or which accounts are online you will need to use the account class.
Posted: Wed Jan 09, 2008 1:39 am
by evands
To keep spam to a minimum, we manage permissions for editing the wiki on a per-user basis. Log out and then back into Trac and you should now find that your account can create and edit pages

Posted: Fri Feb 01, 2008 12:54 am
by mtimmsj
Ok I finally had time to sit down today and iron out the last bits of documenting what I understand of the AppleScript support in 1.2 and later. This information can be found here:
http://trac.adiumx.com/wiki/AppleScript_Support_1.2
I think my next step will be to add a more complicated example of how to use Adium's AppleScript support outside of Adium.
Following that I will try and document how to make an AdiumScript bundle. Comments and revisions are of course welcomed and encouraged.
Posted: Fri Feb 01, 2008 1:36 am
by evands
Great work so far! Thanks for your efforts.
When you feel that it's in a fairly complete form, I think noting this new documentation will be worthy of a blog post.
Posted: Sat Feb 02, 2008 5:33 am
by mtimmsj
One more milestone completed. I've added a fairly complicated example:
http://trac.adiumx.com/wiki/SelectiveSignOn
It's linked to from the main AppleScript page and the Adium 1.2 AppleScript documentation I finished earlier this week.
The last step is to document how to create a "Script Pack" or AdiumScript bundle. I have an example bundle already, just need to put together the documentation.
Posted: Sat Feb 02, 2008 6:00 am
by Catfish_Man
Awesome
