on launched not working

My script starts like this:

on launched theObject
	display dialog "This displays a dialog when your app is launched!"
end launched
on clicked theObject
	if title of theObject = "OK" then
		my the_script()
		quit me
		delay 30
	end if
end clicked

The “on launched” part is not working. It runs like the “on launched” part doesn´t exist.

I have searche the forum and found, there should be dialog examples in /Developer/Examples/AppleScript Studio/.

On my system, there is only “Mail Search”.

Any hints for getting “on launched” running and/or to find the examples for download somewhere are highly appreciated :slight_smile:

Have you connected on launched in Interface Builder?

No. I can´t find it neither. Could not find how to attach screenshot of inspector for you.

In Interface Builder highlight File’s Owner in the Main(Menu.nib) window
In Inspector window select the AppleScript Inspector tab (⌘7) and choose a script from the Script popup menu.
In the Event handler view below check the checkbox Application > launched

Application does´t show up here, but I have helped myself using “opened” for the main window:

on opened theObject
	--do somthing
end opened

I strugle with the options ticked in the inspector quite often. It seem, even I have saved, they are not recognized before closing Interface Builder sometimes.

Thanks Stefan.

Application is only available for File’s Owner or Application, you must select the appropriate item in the main window (.nib or .xib) of Interface Builder not the main window of your application

On Application, all handler checkboxes are greyed out here.

please read post #4 again and follow exactly the instructions