I'm building a "Wizard" of sorts that uses Automator and some Appliescript, and at the end I would like it to generate an "Automator Application" that does things when launched, that are based on the inputs from the wizard.
Is this even possible? Can one Automator workflow, actually generate an application from the results? I know software can create software, but is this possible within Automator's capabilities?
EDIT: As noted in the comments below the post, osacompile
seems like it might get me where I want to go, but now I have a new problem with that.
Here's a screenshot of my automator steps:
Here's the code of the erroring module (Send iMessage):
on run {input, parameters}
set sms_address to item 1 of input
set email_address to item 2 of input
set sms_content to item 3 of input
set email_subject to item 4 of input
set email_body to item 5 of input
set savePath to (path to desktop as text) & "test.scpt"
set code to "osacompile -e 'tell application \"Messages\"' -e '
set imessageservice to 1st service whose service type = iMessage' -e '
set iMessageBuddy to buddy " & sms_address & " of imessageservice' -e '
send " & sms_content & " to iMessageBuddy' -e '
end tell' -o " & quoted form of POSIX path of savePath
do shell script code
return input
end run
Note that the lines are broken up that way because it was the only approach I could find where I didn't get any errors just because of adding line breaks (I can put this code all on one line and get the identical error)
Here's the error I receive:
I haven't been able to figure out what the problem is here but it seems like I'm not passing the variables in the way a bash script expects. Have tried a bunch of other approaches and nothing has worked any better, but this is the one that seems the most sensible to me, knowing how I would normally pass variables into a script.
EDIT 2: To simplify further, here is the standalone code I'm current debugging in AppleScript Editor and without any line breaks to not confuse the issue:
set sms_address to "[email protected]"
set sms_content to "sms content"
set savePath to (path to desktop as text) & "test.scpt"
set code to "osacompile -e 'tell application \"Messages\"' -e ' set imessageservice to 1st service whose service type = iMessage' -e 'set iMessageBuddy to buddy " & sms_address & " of imessageservice' -e 'send " & sms_content & " to iMessageBuddy' -e 'end tell' -o " & quoted form of POSIX path of savePath
do shell script code
osacompile
shell utility can be used to create applets. What kind of "inputs" are you trying to use?osacompile
. If I get something that works, I'll answer the question assuming nobody else has by then.input
) into the shell script without throwing an error. Is there some special method for passing a variable in? I tried using double quotes to drop out of theosacompile
and back again, but no go. What am I missing here... seems like this should be simple. I'm very close to an elegant and complete answer.input
argument is a list, so you would need to coerce, repeat through it, or get an item from it.