Page 1 of 1

Applescript Icon Problem

Posted: Wed May 07, 2008 7:00 am
by HansPinckaers
Hi everyone,

I'm trying to make a simple applescript program that does set the image (icon) of the first account to an image on my dekstop. Here it is:

Code: Select all

tell application "Adium"
	set image of the first account to (open alias "Macintosh HD:Users:Hans:Desktop:buddyicon.tiff" as data)
end tell
When i run it my adium icon jumps once in my dock. I click it and then the message is:

Image

I click "OK" and then applescript tells me that: "Adium did catch an error: application 'Adium' can't be converted into an TIFF picture" ( -> bad translation, my scripteditor is in Dutch)

If i run it from within an Extra i get the same error :)

Thanks for your reply :)

Hans

(srr for my english, i'm dutch O:) )

Re: Applescript Icon Problem

Posted: Wed May 07, 2008 4:31 pm
by mtimmsj
Regarding your english, if you had not said you were Dutch I would not have known. Your typed english is near perfect, much better than most native english speakers.

I think that the only file type that Adium can open is an Xtra. So if you do something like:

Code: Select all

tell application "Adium" to open...
Adium will attempt to open it as an Xtra. That is what leads to the error you are getting about not being able to install the X(tra).

Instead, you will need to open the file for access outside of the tell block and extract the image data out of it then tell Adium to set the image to that data. For example:

Code: Select all

set myAlias to alias "Macintosh HD:Users:Hans:Desktop:buddyicon.tiff"
set myFile to open for access myAlias
set theTiff to read myFile as TIFF picture
close access myAlias

tell application "Adium" to set the image of the first account to theTiff
There may be an easier way to do this, but this seems to work in my simple testing.