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:
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.
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
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 .
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.
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:
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:
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?
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:
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:
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.
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
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:
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.