How to pass AppleScripts display dialog to Growl or growlnotify?

I have this simple AppleScript which takes the text in the clipboard and outputs the amount of words and characters used.

What I’m trying to do is passing “display dialog” to Growl or growlnotify. I know how to use growlnotify in the shell – it’s great and highly customizable (stick note, assign app icon or an image, etc) – but the point is: I don’t know how to do it in AppleScript. I google a bit but now time has passed and I decided to post my question here.

So, here’s the script:

set myCount to count (the clipboard)
set myWords to count words of (the clipboard)
set myParas to count paragraphs of (the clipboard)

display dialog "Characters: " & myCount & "
Words: " & myWords & "
Paragraphs: " & myParas

Thanks.

Answer

There’s documentation for it, I provide an example in this answer.

The following works with Growl 1.3.3 on OS X Lion:

tell application "Growl"
    set the allNotificationsList to {"Word Count"}
    set the enabledNotificationsList to {"Word Count"}

    register as application "Word Counter" all notifications allNotificationsList default notifications enabledNotificationsList icon of application "Script Editor"

    set myCount to count (the clipboard)
    set myWords to count words of (the clipboard)
    set myParas to count paragraphs of (the clipboard)
    --       Send a Notification...
    notify with name "Word Count" title "Word Counter" description (myCount as text) & " " & (myWords as text) & " " & (myParas as text) application name "Word Counter"
end tell

Screenshot of notification

Screenshot of application preferences

Attribution
Source : Link , Question Author : patrick , Answer Author : Community

Leave a Comment