- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在使用 NSUserAutomatorTask
从 macOS 应用启动 Automator 工作流程。
我通过 variables
属性传入变量: https://developer.apple.com/documentation/foundation/nsuserautomatortask/1418099-variables
在 Automator 工作流程中,我将使用 获取变量值
操作来获取在 NSUserAutomatorTask
上设置的变量,并将这些变量传递给后续 Automator 操作:
代码如下所示:(简化;我还在工作流程中check that the variables exist)
let workflow = try! NSUserAutomatorTask(url: url)
workflow.variables = [
"singleFilePath": "/image1.png",
"multipleFilePaths": ["/image1.png", "/image2.png"],
]
workflow.execute(withInput: nil)
我可以通过请求确认
操作打印出警报中的变量值:
String
变量的值是一个简单的字符串:/image1.png
[String]
数组变量的值包含在括号中,并且每一项都用引号引起来:
(
"/image1.png",
"/image2.png"
)
<小时/>
我现在运行如图所示的 Automator 工作流程,该工作流程首先获取变量的值,然后尝试打开这些 Finder 项目。
singleFilePath
var 有效。它被传递到“打开查找器项目”操作,并且该文件由默认应用程序打开。
以相同方式传递multipleFilePaths
不起作用。没有文件被打开。 Automator 显示错误:
<小时/>The action "Open Finder Items" was not supplied with the required data.
该操作是“打开 Finder 项目s”,因此必须有某种方法将多个文件路径传递给此操作。
我的问题和解决方案按优先顺序排列是:
为什么默认变量数组/列表格式在传递给后续操作时不起作用?有没有办法以兼容的格式传递或解析数组变量?
我们可以使用单个 Run AppleScript
操作将数组变量重新格式化为可以传递给后续 Automator 操作的格式吗? (我想继续链接 Automator 操作而不是运行纯 AppleScript)。
最佳答案
如果在正常的非变量工作流程中使用,
打开 Finder 项目
操作可以打开项目数组。而且格式似乎完全相同。
作为测试此功能的控件,而不是变量,我使用 获取指定的查找器项目
操作。
然后,我使用查看结果
操作来检查发送到Open Finder Items
的内容。
结果看起来与我解析变量时的结果完全相同:
(
"/image1.png",
"/image2.png"
)
此工作流程确实正确运行最终操作并打开文件。
因此,Open Finder Items
应该可以使用我在变量中设置的数据。我不确定为什么可变数据无法打开,但手动选取的文件可以。
我针对此问题提交了 DTS 票证并收到以下回复:
I’m sorry to say the engineers working on this have confirmed that yes, it’s a bug, and no, there isn’t a workaround for sandboxed apps. They’ve also noted this isn’t a regression in behavior from previous releases.
关于macos - NSUserAutomatorTask 变量数组/列表值无法被 Automator 操作解析,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61268835/
我正在将一些代码从 AMWorkflow 迁移到 NSUserAutomatorTask,以便最终我可以将我的应用程序沙盒化。我希望能够像在 AMWorkflow 中那样在工作流中设置现有变量的值:
我正在使用 NSUserAutomatorTask 从 macOS 应用启动 Automator 工作流程。 我通过 variables 属性传入变量: https://developer.apple
我正在使用 NSUserAutomatorTask 启动通过 macOS 10.13 中的 Automator 应用创建的 .workflow 文件。 我通过 variables 属性将变量传递到工作
我是一名优秀的程序员,十分优秀!