gpt4 book ai didi

macos - 如何在 Applescript 中调用 Automator 变量?

转载 作者:行者123 更新时间:2023-12-01 19:36:59 25 4
gpt4 key购买 nike

enter image description here

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

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

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

我知道如何通过使用 sys.argv 1 使用 Python shell 脚本来完成此操作和标准输入 -> 参数

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

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

最佳答案

在运行 Applescript 操作中。

您使用 return someVar 输出。

....

return text_returned
end run

Action 的输入通常位于第一个参数中,名称为 输入
on run {input, parameters}
...

enter image description here
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
on run {input, parameters}

set theQuery to input
end run

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

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

如果参数是一个列表,那么您将需要使用例如:
 on run {input, parameters}

set theQuery to item 1 of input
end run

另请注意,如果您从 applescript 上下文/菜单脚本中获取显示对话框代码,它将为您提供以下行: copy the result as list to {button_pressed, text_returned}
要在 Automator 中使用它,您需要交换: {button_pressed, text_returned}{text_returned, button_pressed}
( 去搞清楚..!)

关于macos - 如何在 Applescript 中调用 Automator 变量?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21391889/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com