Your AppleScript Studio app is already very scriptable. Try creating a button called “receiver” that is placed behind a text view or just out of the bounds of the main window. Then attach an “on clicked” handler to the button that does something useful. Now, from anywhere (including the shell) you can have your app receive an event and do something useful with this code:
tell application "yourapp" to tell button "receiver" of window "main" to perform action
You’re right that you can use “osascript” to trigger this from a shell script:
osascript -e 'tell application "yourapp" to tell button "receiver" of window "main" to perform action'
Oh, sure, you can add a full custom scripting dictionary to your app but the overhead is huge and so not worth it (see the MacScript FAQ for more info). If you just want to fill in text fields and the like, the same code you use inside your app is available outside of it (e.g., set contents of text field “x” to “123”) but for running custom handlers, this is far and away the easiest (and in my opinion) most elegant way of handling scriptability.
I take it all back the “hidden button” approach is very elegant.
I am actually able to include hidden buttons in a window (it is a tickable property in Interface Builder). Therefore there is no need (as far as I can see) to hide them behind another object of off the edge of the window as suggested above.
It was the suggested physical placement of the buttons in hard to see places which I considered to be “unelegant” :lol: