AppleScript with Growl

今天繼續研究登入時讓電腦說話之外還可以有什麼作為,想到的就是結合Growl的訊息通知功能,讓電腦除了讓你聽得見也能看得見。

Growl是套有趣的程式,它的功能就是將其他軟體接收與釋放的訊息顯示在螢幕的一角。Windows的使用者應該都有看過畫面右下角,來自防毒軟體、msn與系統的警告訊息吧!那些氣泡訊息其實就是Growl在麥金塔上扮演的角色,你可以自由控制那些訊息的外觀、音效來告知你該注意什麼消息。我最喜歡的大概就是Adium與它的結合,當朋友傳即時訊息給我時,就算我不用開啟聊天室窗也能看到對方傳給我什麼訊息,永遠不會漏接。

tell application "GrowlHelperApp"

set the allNotificationsList to {"Test Notification", "Another Test Notification"}

set the enabledNotificationsList to {"Test Notification"}

register as application "Login Message" all notifications allNotificationsList default notifications enabledNotificationsList icon of application "Script Editor"

notify with name "Test Notification" title "Welcome" description "At your service, Sir." application name "Login Message" image from location "file:///Users/LiFong/Pictures/evan.jpg"


end tell




  1. 呼叫GrowlHelperApp
  2. 製作全訊息清單,內容來自Test Notification與Another Test Notification。(這名稱是官方取的,可以隨意改變)。
  3. 製作可通知清單,內容來自Test Notification當中。
  4. 註冊本Script到Growl的應用程式列表中,以後你可以在Growl當中修改進階的設定,這邊我設定了程式名稱(application name)為:Login Message,圖示來自於Script Editor。
  5. Notify中有五項設定,分別是name(我們自定的訊息清單名稱)、title(標題)、description(描述:通知視窗的內容)、application name(程式名稱)與image from location(氣泡訊息的圖示路徑)。如果你在後頭加上個Sticky yes,那就可以讓訊息持續顯示直到你關閉它。





附上本日使用Repeat 重複語法的失敗畫面,原本我想讓訊息一下子就會消失的Growl可以多顯示幾次就設定了repeat,結果是夢魘一場....(笑)


Ref.
  1. Adam Nolley 及 Diggory Laycock, “AppleScript Support for Growl,” Growl, 無日期, http://growl.info/documentation/applescript-support.php.
  2. dfabulich, “sticky applescript notifications,” cocoaforge, 七月 14, 2008, http://forums.cocoaforge.com/viewtopic.php?f=6&t=17837.

小泉

喜愛用文字說明自己眼中所見的一切

張貼留言

較新的 較舊

نموذج الاتصال