我想使用AppleScript打开Automator并将特定操作添加到新的工作流程,而不管本地化设置(语言)如何。换句话说,我想使用AppleScript打开一个新的Automator工作流,并使用每个操作的包标识符(以避免语言问题)或以其他方式避免语言问题,以特定顺序(在索引处)添加特定操作。
问题在于我无法让Automator向工作流程添加任何内容。
add
命令的语法是什么? 到目前为止,这就是我所拥有的:
tell application "Automator"
make new workflow with properties {name:"Merge PDF Files"} -- Skips Opening Dialog
add "Get Specified Finder Items" to workflow 1 at index 1 --("com.apple.Automator.SpecifiedFiles")
add "PDF-Seiten kombinieren" to workflow 1 at index 2 --("com.apple.action.joinpdf")
end tell
在bwaldie发布他的回答之后,我想分享我的有用液滴。你可以将它放在任何运行OS X的Mac上(对于不熟悉Automator的人特别有用)。要使用它,只需将代码粘贴到AppleScript编辑器中并将其另存为应用程序。
请参阅droplet的代码:
on open the_Droppings
-- CONVERT INPUT LIST OF ALIASES TO POSIX PATHS
repeat with itemStep from 1 to count of the_Droppings
set item itemStep of the_Droppings to POSIX path of item itemStep of the_Droppings
end repeat
tell application "Automator"
activate
set theWorkflowName to "Merge PDF Files"
set msg to "no"
tell application "Finder" to if exists POSIX path of ((path to temporary items as string) & theWorkflowName & ".workflow" as string) as POSIX file then set msg to "yes"
if msg is "no" then
set myWorkflow to make new workflow with properties {name:theWorkflowName, path:POSIX path of ((path to temporary items as string) & theWorkflowName & ".workflow" as string)}
add (first Automator action where its id = "com.apple.Automator.SpecifiedFiles") to myWorkflow at index 1
add (first Automator action where its id = "com.apple.action.joinpdf") to myWorkflow at index 2 --("com.apple.Automator.SpecifiedFiles")
else
set myWorkflow to open POSIX path of ((path to temporary items as string) & theWorkflowName & ".workflow" as string)
end if
set actionsList to name of Automator action of myWorkflow
set firstAction to item 1 of actionsList
tell myWorkflow
set value of setting of Automator action firstAction to the_Droppings -- MUST BE LIST OF POSIX PATHS
end tell
end tell
end open
答案 0 :(得分:1)
尝试一下......
set theWorkflowName to "Merge PDF Files"
tell application "Automator"
set myWorkflow to make new workflow with properties {name:theWorkflowName, path:POSIX path of ((path to desktop folder as string) & theWorkflowName & ".workflow" as string)}
save myWorkflow
add (first Automator action where its id = "com.apple.Automator.SpecifiedFiles") to myWorkflow
end tell
我认为关键是创建工作流程,然后保存,然后添加操作。
希望这有帮助!
-Ben
答案 1 :(得分:0)
如果您想使用Automator,则无需编写脚本。这对我有用:
您可能需要稍微调整并尝试使用Automator,以确保它完全符合您的要求。