问题描述
我想在 Applescript(在 Automator 内部)中使用 Automator 变量,但我没有在网上找到任何有关如何操作的信息。 This is my Automator project,这里是 Applescript:
tell application "Finder"
delete file Path
empty trash
end tell
end run
解决方法
Automator 是可编写脚本的,因此在工作流中您可以只使用其术语,例如:
set thePath to value of variable "Path" of front workflow
tell application "Finder"
delete file thePath
empty trash
end tell
请注意,path
是一个参数名称,因此我在脚本中为其使用了不同的变量名称。
另一种选择是使用 Get Value of Variable
并将其传递给 Run AppleScript
操作,例如:
-
索取文字
-
设置变量值 {变量:测试}
-
-- 其他工作流程的东西 --
-
获取变量的值 {变量:测试}(忽略输入)
-
运行 AppleScript
on run {input,parameters} -- input is from the previous action set theValue to (first item of input) as number -- input is always a list if theValue > 1 then display dialog "It works!" -- return item(s) to the next action as needed end run