目前,我设置了一个流程,该流程会导致一个文件——“cb.txt”——被添加到我的 Dropbox 中。我收到一条 Growl 通知,其中包含应用程序名称“Dropbox”和注释标题“cb.txt added”。我希望'cb.txt added'通知运行一个applescript,它将文本从cb.txt复制到我的剪贴板。Growl 的通知规则可以在这里找到。
这是我要运行的applescript(当我通过Applescript自行运行它时,它成功地将cb.txt的内容添加到剪贴板):
set the_file to "HardDrive:Users:Me:Dropbox:Folder:cb.txt"
set the_text to (do shell script "cat " & quoted form of (POSIX path of the_file))
set the clipboard to the_text
我已将此文件保存~/Library/Application Scripts/com.Growl.GrowlHelperApp
为苹果脚本。我还使用此代码保存了另一个版本:
using terms from application "Growl"
on perform action with notification
ignoring case
if notification's app name is Dropbox then
if notification's note title contains "cb.txt added" then
set the_file to "Macintosh HD:Users:Caleb:Dropbox:Apps:CBApp:cb.txt"
set the_text to (do shell script "cat " & quoted form of (POSIX path of the_file))
set the clipboard to the_text
end if
end if
end ignoring
end perform action
end using terms from
前面的脚本在运行时不执行任何操作。我将其保存为 Rules.scpt:
using terms from application "Growl"
on evaluate notification with notification
--Rules go in here
--Ultimately return what you want Growl to do with the notification
end evaluate notification
end using terms from
显然,我有点卡住了。如果有人可以就如何在我收到特定的 Growl 通知时运行我的工作 Applescript 代码提供建议,我将不胜感激!