I’m running applescript no problem by saving as a script, copying into the build and referencing the script in an action. Works great. I wondered if there is anyway to run the script by say storing it in the action itself. I’d like the app to compile without storing the script in the resources folder so it can’t be accessed in the build package if that makes sense ?
Here is an example project that will execute an applescript saved as a constant in your app (or from a text area as in my example). Just click the button it will execute the script in the text area. If you need parameter, look at the link I posted earlier and add those to the shell command.
or use a single line text with -e ’ on the beginning of every applescript line and ’ on the end of every applescript line
/usr/bin/osascript -e 'tell application "System Events" to activate' -e 'tell application "System Events" to return (choose from list {"Liste1", "Liste2"} with prompt "Choose a Project Type:" with title "Project Type Chooser" OK button name "Select" cancel button name "Quit")'
wow …thanks all for the info. Loads to learn! I ended up going with Jasons example and modify the text area to be a constant as a string ( which in itself was a lightbulb moment so thanks) Seems to work fantastically for what I need. I have noticed though that if I put in a script that requires a dialog box,even something as simple as :
Then all i get in the dialog window is the number 1 . Not what I was expecting. Any ideas why ?[/quote]
Ah, yes - let me fix that. The 1 is the error code from the shell command. I’ll have a new version posted in just a minute.
Updated project - this one should work as desired. Make sure the kScriptRunner constant is included or it won’t work if you copy the method to a new project.