如何在 Applescript 中调用 Automator 变量?

O.r*_*rka 5 variables macos applescript arguments automator

在此处输入图片说明

所以我有一个显示对话框的 Applescript,然后自动机将变量设置为条目

例子 。. . 输入“AAAAAAA”查询变量将是“AAAAAAA”

我正在尝试找出一种在运行我的下一个 applescript 时调用变量的方法

我知道如何通过使用 sys.argv 1和 stdin -> 参数来使用 Python shell 脚本

我怎样才能用 Applescript 实现这一点?

我看到了一个类似的帖子标题,但答案没有解决这个问题

mar*_*nte 5

在运行 Applescript 操作中。

您使用 return someVar 进行输出。

....

return text_returned
    end run
Run Code Online (Sandbox Code Playgroud)

操作的输入位于第一个参数中,通常是名称输入

on run {input, parameters}
...
Run Code Online (Sandbox Code Playgroud)

在此输入图像描述

on run {input, parameters}

    display dialog "test" default answer "" buttons {"Cancel", "OK"} default button 1
    copy the result as list to {button_pressed, text_returned}

    return text_returned
end run
Run Code Online (Sandbox Code Playgroud)
on run {input, parameters}

    set theQuery to input
end run
Run Code Online (Sandbox Code Playgroud)

在这种情况下,如果您想重用它,则只需要设置变量。

在此示例中,您可以将其删除并仍然得到相同的结果。

如果参数是一个列表,那么您将需要使用例如:

 on run {input, parameters}

        set theQuery to item 1 of input
    end run
Run Code Online (Sandbox Code Playgroud)

另请注意,如果您从 applescript 上下文/菜单脚本获取显示对话框代码,它将为您提供以下行:copy the result as list to {button_pressed, text_returned}

要在 Automator 中使用它,您需要将 : 交换{button_pressed, text_returned}{text_returned, button_pressed}

( 去搞清楚..!)