Wie übergebe ich den Anzeigedialog von AppleScripts an Growl oder Growlnotify?

Wie übergebe ich den Anzeigedialog von AppleScripts an Growl oder Growlnotify?

Ich habe dieses einfache AppleScript, das den Text in der Zwischenablage nimmt und die Anzahl der verwendeten Wörter und Zeichen ausgibt.

Ich versuche, „Dialog anzeigen“ an Growl oder Growlnotify zu übergeben. Ich weiß, wie man Growlnotify in der Shell verwendet – es ist großartig und sehr anpassbar (Notiz anheften, App-Symbol oder Bild zuweisen usw.) – aber der Punkt ist: Ich weiß nicht, wie man es in AppleScript macht. Ich habe ein bisschen gegoogelt, aber jetzt ist die Zeit vergangen und ich habe beschlossen, meine Frage hier zu posten.

Hier ist das Skript:

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

Danke.

Antwort1

Es gibtDokumentationdafür gebe ich ein Beispielin dieser Antwort.

Folgendes funktioniert mit Growl 1.3.3 unter 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 der Benachrichtigung

Screenshot der Anwendungseinstellungen

Antwort2

set input to the clipboard as text
set output to (number of characters of input & " characters
" & number of words of input & " words
" & number of paragraphs of input & " paragraphs") as text
do shell script "/usr/local/bin/growlnotify " & quoted form of output
-- brew install growlnotify

verwandte Informationen