Incidentally, for the Mac-heads out there:
There is a particular advantage in using the "inline" method I presented above.
The only caveat to this is that I do not have Snow Leopard yet, so I have no idea if any of this functionality is broken in OS 10.6+.If you run the osascript command
without the "-e" option, specifying a script file, you cannot have user interaction (using, for example, AppleScript's "display dialog" command). But using the "-e" option allows this sort of thing, and this includes running this command using callSystem in an AE jsx.
So, you can do the following, which has two osascript calls in one callSystem line (go ahead and try it -- and if
you have Snow Leopard, I would much appreciate feedback on whether or not this works in the latest OS:
Code:
system.callSystem('osascript -e \' activate application "Finder"\' ; osascript -e \' tell application "Finder" to display dialog "Is this amazing?" buttons {"Slightly"} default button 1 \'');
Apologies for the long line. Spaces are added for readability. Of course, each callSystem/osascript command can be written in separate lines:
system.callSystem('osascript
... (first)system.callSystem('osascript
... (second)I just wanted to show what you could do with one line if you wanted.
This essentially makes the jsx/applescript possibilities limitless, although wrangling single quotes, double quotes and escaped quotes can be annoying.
-CG