Cocoa and AppleScript

  • Hi All,

    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....

    I would like to see what I am doing wrong.

    Thanks,

    -Jason
  • 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
previous month may 2008 next month
MTWTFSS
      1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31  
Go to today