如何使用applescript进行咆哮通知?

时间:2012-10-31 17:43:16

标签: macos growl growlnotify

我正在使用一个脚本来更新我的SVN工作副本。

我已经安装了Growl。我希望在脚本完成SVN的工作副本更新后发出Growl通知。

请帮帮我。

2 个答案:

答案 0 :(得分:3)

在Google和Growl网站上进行一些搜索可以解决您的问题。

Click here了解它。

或直接将此代码粘贴到您的苹果脚本编辑器中,看看它是如何工作的。

tell application "System Events"
    set isRunning to (count of (every process whose bundle identifier is "com.Growl.GrowlHelperApp")) > 0
end tell

if isRunning then
    tell application id "com.Growl.GrowlHelperApp"
        -- Make a list of all the notification types 
        -- that this script will ever send:
        set the allNotificationsList to ¬
            {"Test Notification", "Another Test Notification"}

        -- Make a list of the notifications 
        -- that will be enabled by default.      
        -- Those not enabled by default can be enabled later 
        -- in the 'Applications' tab of the Growl preferences.
        set the enabledNotificationsList to ¬
            {"Test Notification"}

        -- Register our script with growl.
        -- You can optionally (as here) set a default icon 
        -- for this script's notifications.
        register as application ¬
            "Growl AppleScript Sample" all notifications allNotificationsList ¬
            default notifications enabledNotificationsList ¬
            icon of application "Script Editor"

        --       Send a Notification...
        notify with name ¬
            "Test Notification" title ¬
            "Test Notification" description ¬
            "This is a test AppleScript notification." application name "Growl AppleScript Sample"

        notify with name ¬
            "Another Test Notification" title ¬
            "Another Test Notification :) " description ¬
            "Alas — you won't see me until you enable me..." application name "Growl AppleScript Sample"

    end tell
end if

我希望这可以解决你的问题。

答案 1 :(得分:0)

我更喜欢在脚本中使用GrowlNotify(http://growl.info/extras.php#growlnotify)。这是通过AppleScript咆哮的一种更简单,更直接的方式。