Skip navigation.
 
mlRe: Cocoa and AppleScript
FROM : has
DATE : Mon May 26 22:36:43 2008

J. Todd Slack wrote:

> Can anyone point me to an example (maybe a downloadable .zip) of an
> XCode project that when the app it runs it runs an applescript, does
> not display any windows  or anything....maybe just displays "Hello
> World" in a display dialog  by using "on run"
>
> I am somewhat confused as I tried creating a default AppleScript
> application and adding "on run" to the applescript and it does not
> work....



Note that AppleScript Studio questions should be directed to the 
applescript-studio mailing list:

   http://lists.apple.com/mailman/listinfo/applescript-studio

To answer your question:

Desktop Cocoa applications are event driven. Studio-based applications 
consist of a Cocoa-based wrapper around one or more AppleScript script 
objects. For the script to do anything, the wrapper has to send it an 
event. To hook up the outer wrapper with the inner script, you use 
Interface Builder.

For example, to send an event when the application has finished 
launching, once you've created your AppleScript Studio project, open 
MainMenu.nib and select the main 'Application' object. In the 
Inspector palette, which is now showing the attributes for the 
Application object, click on the tab with the AppleScript icon. In the 
'Script' menu, select the name of the script you want it to send 
events to, then in the 'Event Handlers' list select 'Application > 
Launched'. Save MainMenu.nib, then go back to Xcode and open the 
script - you'll find an empty 'on launched ...' handler has been added 
to which you can add the code that you want executed when the 
application has finished launching.

HTH

has
--
Control AppleScriptable applications from Python, Ruby and ObjC:
http://appscript.sourceforge.net

Related mailsAuthorDate
mlCocoa and AppleScript J. Todd Slack May 26, 21:43
mlRe: Cocoa and AppleScript has May 26, 22:36