【发布时间】:2013-08-20 03:44:04
【问题描述】:
目前,我设置了一个流程,该流程会导致一个文件——“cb.txt”——被添加到我的 Dropbox。我收到一条 Growl 通知,其中包含应用程序名称“Dropbox”和注释标题“cb.txt added”。我希望'cb.txt added'通知运行一个applescript,它将文本从cb.txt复制到我的剪贴板。咆哮的通知规则可以在here找到。
这是我要运行的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 代码提供建议,我将不胜感激!
【问题讨论】:
-
我在该教程页面中没有看到他们提到应用程序名称的任何地方,您是否尝试过不使用该 if 语句?另外,你试过把“Dropbox”放在引号里吗?
-
嗨@josh,Growl 页面没有更好地显示这一点并不让我感到惊讶。我有时会发现他们的页面缺乏细节。因为您使用的是应用程序“Growl”中的术语,所以您可以使用咆哮 sdef 的任何属性,只要它们以正确的方式使用。如果您不能使用应用名称,那么评估多个规则将更加困难。
标签: applescript dropbox growl