Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Apple Scripting an existing Cocoa Application



Hello,

I have some elementary questions on AppleScripting an existing Objective-C/C++ Cocoa application that is not currently scriptable. I want to select menu items via AppleScript.

First, some design philosopy questions. Do people feel that it would be better to just implement generic Apple Events in Objective-C rather than making the modified application AppleScriptable? It seems that AppleScripts are really just layers over Apple Events. However, It might be nice to be able to just issue a script from a terminal or from another application.

I was hoping that Project Builder or Interface Builder would have some user friendly method of automating scriptable components and defining their syntax. I have NOT found such a user friendly solution for ApleScripts nor Apple Events. Also, the project builder / interface builder documentation seems to be very sparse with regard to AppleScripts and Apple Events.

There is AppleScript Studio but that seems focused on making application GUI's where the callbacks and event handlers are AppleScripts instead of Objective-C. Also, AppleScript Studio seems to be just Project Builder and Interface Builder together with AppleScript. You create a new project and select AppleScript Application from the list of PB templates. It gets AppleScriptKit.framework added to the project and an AppleScriptKit.asdictionary. So, now you just drag and drop in Interface Builder and assign names

There are several AppleScript documents at the Apple developer web site. One is "Guidelines for Creating Scriptable Applications". Suppose you already have a pure Objective-C Cocoa app with no internal scripts but just Objective-C and C++ code and you want to add AppleScript support. It seems like you have to do the following.

Turn On Scripting in the application
Create Suite Definitions and Suite Terminology
Implement Scripting Methods (this step is somewhat obscure)
Define a New Script Command

I also spotted some initialization code when I made a blank new AppleScript Application in IB. I just added names in the applescript pane of the info window in Interface Builder and Built the project. It died on launch with a SIGBUS error so maybe that was the problem. However, from the list above there is a lot of actions that have to perfromed to AppleScript enable an existing application. Creating one from scratch seems be straightforward.

Is there a more simple procedure for AppleScript enabling an existing Cocoa application? Perhaps something in Project Builder that I am missing.

If someone has some lessons learned to share or maybe some textbook they like please feel free to mention it.

John F. Richardson
_______________________________________________
applescript-studio mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/applescript-studio
Do not post admin requests to the list. They will be ignored.



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.