How do I make an applet?

Hello,
I just started scripting and am working on a very simple new script that I would like to run every time iTunes launches. From what I understand, I have to make the script an applet and somehow associate it to open when iTunes runs. However, I’m not really sure how to do this. I googled “applescript applet” and perused macscripter a bit, but I couldn’t find anything. Any help would be appreciated.

For reference, this is the script I am trying to make an applet.

on run
	tell application "iScrobbler"
		run
	end tell
	tell application "Album Art Thingy"
		run
	end tell
	tell application "ByteController"
		run
	end tell
	tell application "QuickTunes"
		run
	end tell
end run

Model: MacBook Pro 2.4 GHz Core 2 Duo 4GB RAM
Browser: Firefox 2.0.0.8pre (Mac Community Build, ElFurbe)
Operating System: Mac OS X (10.4)

Hi and welcome.

It’s very easy to make a script an applet: Just save it as an application.
But you cannot easily trigger a script when an application launches.
I recommend to use a script, that launches iTunes and then the other applications.

activate application "iTunes"
activate application "iScrobbler"
activate application "Album Art Thingy"
activate application "ByteController"
activate application "QuickTunes

Notes: the keyword run is used to run a script (object). To run an application use launch or activate.
The difference is, launch just runs the app without bringing it frontmost or opening any windows.
activate is the same as doubleclicking the app in the Finder or start it from the dock.

The run handler (on run) is not mandatory. AppleScript takes all top level code implicitly as run handler

Hey, thanks for the response. I misunderstood what the term applet meant.

Basically, what I want the script to do is launch a few helper programs when iTunes opens. I think the best way to do that would be to create a conditional script and save it as an applet. Then add the applet as a login item. However, I’m having trouble setting up the conditional. I’m not sure what it should say. I would also like the applet to close when it completes the conditional.

Below is the script I’m working on. I get the following error message: “iTunes got an error: Can’t make some data into the expected type.”

if application "iTunes" open then
	
	activate application "iScrobbler"
	activate application "Album Art Thingy"
	activate application "ByteController"
	activate application "QuickTunes"
end if

As I said above, you cannot trigger a script directly when an application starts.

You have two options:

  1. use the script in my last post, save it as application and run the script instead of launching iTunes.
    It will launch iTunes and your helper apps

  2. save the following script as an stay open application and run it.
    It checks every 5 seconds if iTunes has been launched, and starts the helper apps, if necessary

on idle
	tell application "System Events" to exists process "iTunes"
	if result then
		activate application "iScrobbler"
		activate application "Album Art Thingy"
		activate application "ByteController"
		activate application "QuickTunes"
		quit me
	end if
	return 5
end idle

I would prefer version 1