Applescript Input into Automator input...
I have a nice little applescript (on run.. inputObects) that presents a list of actions to perform on the files dropped. One of these actions is a simple copy using cp in the shell. Everything works great, execept, I need a way to cancel the script. yes, I could do a file > Quit on the scrip App. But, for my users, that is not convenient. I like how automater puts a 'cog' in th menubar that you can 'cancel' a script with. However, my applescript is too complicated for automator as the main app because of resources and other things I am doing.
I tried creating a 'dummy' automater script that delays indefinently but has an 'on quit' hander quitting the main applscript app. However, when choosing to 'cancel the workflow' from the cog, it does not run the worflows 'on quit' handler.. and thus does not solve my problem.
That said, I desire to change to bavior for the applscript to open an automater app that does the actions instead of nesting them in my main script....Unless there is a better way to implement a "cancel" of Applscript while it is doing 'stuff'.
So, does anyone know how to send the same input from the dropped-on file into the automator's inputs? and then get the return?
here is a code scketch.. very simplified.
mainApp.app (applescript read-only app):
on open of inputObjects
set workerPath to quoted form of POSIX path of (path to resource "Worker.app" in directory "Scripts")
do shell script "open " & workerPath & inputObjects
-- now, get the output form the automator script..
display dialogallNames
end open
Automator, applescript (Worker.app):
on open of inputObjects
repeat with i in inputObjects
set fileCopies to fileCopies & inputObjects
set fposix to the quoted form of the POSIX path of i
do shell script "cp -f " & fposix & " ~/Desktop/"
--- GET ALL THE FILENAME(S) of files dropped
set oD to AppleScript's text item delimiters
set AppleScript's text item delimiters to {"/"}
set fileName to (last text item of fposix)
set AppleScript's text item delimiters to oD
set AppleScript's text item delimiters to "."
if number of text items of fileName > 1 then
set finalName to text items 1 thru -2 of fileName as text
end if
set allNames to allNames & "\n" & finalName
end repeat
return allNames
end open