【问题标题】:Mac Automator/AppleScript: Is there a way to refer to Variables within AppleScript?Mac Automator/AppleScript:有没有办法在 AppleScript 中引用变量?
【发布时间】:2012-12-02 01:24:02
【问题描述】:

我在互联网上看到了很多关于此的问题,但没有答案。有没有办法在 AppleScript 中引用 Automator 的“变量”?我想做一些字符串操作作为工作流程的一部分。我已经通过使用 Get Variable 并将它们传递到临时文件来解决这个问题,但这有点难看。

【问题讨论】:

    标签: macos applescript automator


    【解决方案1】:

    我正在尝试和 Steven 一样的尝试。我的结论是,当您在“Automator”应用程序中运行流程时,您的 AppleScript 可以通过 Apple Script“Automator Suite”界面访问 Automator 变量。例如:

    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"
    

    但是,如果您将流程保存为独立应用程序,则它不会将“Automator Suite”包含到应用程序中,因此上述脚本将不再起作用:-(

    【讨论】:

    • 感谢更新!这听起来很有希望,但听起来还没有完全成熟。我下次使用 Automator 时会使用它……
    【解决方案2】:

    工作流中使用的 AppleScript 接受两个参数:input,即前一个工作流的输出,以及parameters,工作流 UI 中设置的选项(如果适用)。如果您正在操作的字符串是工作流输入的一部分,它将位于input

    更多信息请见here

    【讨论】:

    • 谢谢。根据您的回复,我尝试转储“参数”(带有“返回参数”),其中有一些有趣的东西,但不包含我用“设置变量值”设置的自动机“变量”。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2014-02-18
    • 2013-10-12
    • 2023-03-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-03-25
    相关资源
    最近更新 更多