【发布时间】:2013-08-31 05:51:07
【问题描述】:
我创建了两个 Droplet,一个用于重命名文件,另一个用于打印文件。它们比这更复杂,但这就是本质。有时我们只需要重命名它们,有时只需要打印它们,有时两者都做。由于每个用户都需要进行大量自定义,因此我更愿意将两个液滴分开。
所需的工作流程:将文件拖动到 RenameMe 液滴,如果按住命令键,则将重命名的文件传递给 PrintMe 液滴。
借助 checkModifierKeys 脚本(抱歉,手边没有引用),我可以检查是否按下了命令键,以便处理脚本的一部分。问题是如何从第一个液滴触发第二个液滴。我尝试使用第二个 droplet 作为应用程序打开文件(如下面的代码所示),但出现通信错误。
有什么想法吗? --亚历克斯
示例代码:
on open the_Droppings
set flPth to POSIX path of (path to me) & "Contents/MacOS/checkModifierKeys"
set cmdPressed to (do shell script (quoted form of flPth & " command")) as integer as boolean
repeat with i from 1 to (count of items in the_Droppings)
set file_name to "NEW NAME FROM SCRIPT" #actual script that generates name isn't relevant
tell application "Finder"
set name of file (item i of the_Droppings) to file_name
end tell
if cmdPressed is true then
#pass the file to the PrintMe droplet
tell application "PrintMe"
open (item i of the_Droppings)
end tell
end if
end repeat
end open
【问题讨论】:
-
为什么不在 RenameMe 脚本应用程序包中保留另一个脚本的别名(甚至是副本),然后每次都调用它?
-
这是相同的工作流程@MondoJobsNY was tweeting this morning吗?
标签: applescript