在 Applescript 中使用自动变量

问题描述

我想在 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
    

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...