Local Links

External Links

Contact

Search this site

Making your Xojo OS X application scriptable (AppleScript)


This page gives a brief intro about making your application scriptable, i.e. via AppleScript.

Summary of the steps necessary:

  • Process incoming AppleEvent requests in the App.HandleAppleEvent event handler or by using my Cocoa Scripting framework (see below).
  • Write a AppleScript Vocabulary (sdef) describing the available commands (check out the Sdef editor).
  • When building your app, add the sdef file to the app's Resources folder, and add two keys to the app's Info.plist file to let OS X know that this app is scriptable.

Download

AppleEvent Demo (zip file, last updated Mar 13, 2016)

The demo shows how to handle a few custom commands where values (text or number) are passed as arguments and a value is then returned after the command has been handled by the Xojo code inside App.HandleAppleEvent.

See the Notes section in the App class for more information and instructions.

Cocoa AppleScripting framework for Xojo (added in 2018)

For the Xojo-made application iClip I have written a very smart layer that makes Xojo classes semi-automatically scriptable. The documentation is lacking, but it comes with a demo projec that shows most of its abilities. If you are interested in using the framework and need assistance, contact me.

Further information (a bit outdated)

  • Developing AppleScriptable Xojo Applications
  • Thomas Reed wrote an article on adding scriptability to Xojo (REALbasic) apps back in issues 1.5 and 1.6 (April/May and June/July 2003) of the REALbasic Developer magazine, now xdev. It goes into more depth, along with using classes so that one can write "set x of window 1 to 123". Ignore the parts on writing an 'aete' resource and using the EightyRez app, though. That's outdated and is replaced by using 'sdef' files now. Here's an updated version of the sample code.
  • To debug, use these commands to enable output of sent and received AEdesc to the Terminal:
export AEDebug=1
export AEDebugSends=1
export AEDebugReceives=1
Then launch the built app from the same terminal cmd line, using the app's path plus /Contents/MacOS/executableName (the open command won't work for this).

Page last modified on 2019-02-08, 15:40 UTC (do)
Powered by PmWiki