Mac Automator/AppleScript: Is there a way to refer to Variables within AppleScript?
-
28-09-2019 - |
문제
I've seen a lot of questions about this on the interwebs but no answers. Is there a way to refer to an Automator 'variable' within AppleScript? I'd like to do some string manipulation as part of a workflow. I've worked around this by using Get Variable and passing them into temporary files, but it's kind of ugly.
해결책
An AppleScript used in a workflow accepts two parameters: input
, or the output of the previous workflow, and parameters
, the options set in the workflow's UI (if applicable). If the string you are manipulating is part of the workflow's input, it will be in input
.
More information is available here.
다른 팁
I was trying the same ting as Steven. My conclusion is that when you run a flow inside the "Automator" application then your applescript can access Automator-varaibles via the Apple Script "Automator Suite" interface. For example:
set my_variable to value of variable "The Variable" of workflow 0 of current application
display dialog my_variable as text
set my_variable to "Test"
But if you save the flow as a stand alone application then it does NOT include the "Automator Suite" into the application and therefore the above script will no longer function :-(