View Full Version : Applescript Application icon

Jun 21, 2004, 04:59 PM
I'm using the script editor to launch the following script:

tell application "Finder"

open "Macintosh HD:MacPlay Games:realMYST:realMYST.cdr"

delay 5

open "Macintosh HD:MacPlay Games:realMYST:realMYST"

end tell

Don't worry. I have a laptop and like most of us probably do, I make CD Images to run my games.

So I wrote this wimpy script in the Script Editor which opens the .cdr file (which mounts it), it waits 5 seconds (to give it time to mount) and then it launches the game. There's probably a more crafty way to do this and I'm all ears for that (or to get the disc image to unmount post gameplay or instead of a delay that it could just scan for the image to be mounted and run once the image is mounted instead of my arbitrary 5 second time).

However my question is that now that I've saved it as an Applescript Application and I can get it to reside on my dock, is there any way I can get the icon changed for this particular one? I don't want to change all Applescript Applications to a Myst icon. I went into the info via Finder for the application and couldn't figure out how to change it there. Any suggestions/solutions? It's not needed right now particularly but if I do this for more than just Myst I'd hate to have 5 Applescript icons on my dock.

Thanks much!

Well durn. It seemed to work fine when I had the Script Editor open but then I closed the script editor and whenever I launch the script it attempts to launch Classic which I don't have installed (I started in OS X so no need for old programs really). So if you have an idea about that that'd be helpful too.

Jun 21, 2004, 06:10 PM
about your classic issue... I can't answer that one right away, I used to have it with a script to launch IE and clear the cache and all the cookies before running (a friend who has some public computers in his bar wanted this so each time someone comes over to use it they get a fresh new browser) the issue than was that I had to rename the IE for OS9 so the finder only found the OSX version... problem solved there... but I guess its different in your case...

<edit> about the delay, I think its the only way of doing that in applescript, I use it allso for the script wich launches my messenger program (dMSN 1704) I'm on AirPort in my studio and it needs a delay before starting-up or otherwise I get a 'no network available' error...
<end edit>

so about the Icon...

just find a file or folder or just an iconfile wich has the image you want to use

choose 'info' on both files, select the image in the infoscreen wich you want for you app press apple+c select the icon of your applescriptapp in that infoscreen, and just apple+v... easy as that ;-)

be sure that you select the icon in the infoscreen first before doing anything (it gets a blue 'shadow') otherwise it won't work...


Jun 21, 2004, 07:18 PM
AppleScript has always had a nasty habit of "remembering" the wrong application as the target of the script, especially if you have more than one copy of the app (different versions, multiple hard disks w/copies).

I used to rename apps with the version number in the file name so I could see exactly which app the AppleScript was targeting, but it still would get messed up every once in a while.

To fix it:

Just re-open the script and change "Finder" to "Finder.app" and hit the Enter button (that compiles the AppleScript).

It will change back to "Finder", but the internal AppleScript should point to the actual Mac OS X Finder application now.

You have to do this for pretty much any Mac OS X app with an .app extension the first time (thanks Apple!).

That should work.

Jun 21, 2004, 08:36 PM
Thanks for your help, both of you. I successfully got the Applescript icon changed. However, it must be still looking for the classic Finder.app. Is there a more direct path I can put instead of Tell Application "Finder.app" (which does change to "Finder"). The script works fine in the script editor but not as a Application.

Thanks again! Here is the code pre-compile:

tell application "Finder.app"

open "Macintosh HD:MacPlay Games:realMYST:realMYST.cdr"

delay 5

open "Macintosh HD:MacPlay Games:realMYST:realMYST"

end tell

Like noted above, it switched to Finder but still to no avail.

Jun 21, 2004, 09:13 PM
Well... I even tried:

tell application "Macintosh HD:System:Library:CoreServices:Finder.app"

When I compiled it it didn't switch to just Finder which made me hopeful. It worked in the script editor. But as soon as I made it an Application... nope.

I suppose I could write a full blown cocoa thingie to do it but that just seems ridiculous.

I looked around a few spots in some Applescript forums but didn't find much of anything (although I did find out how to unmount the disk but not "when Myst quits").