Skip to content

Instantly share code, notes, and snippets.

@apcomplete
Created October 2, 2013 20:26

Revisions

  1. apcomplete created this gist Oct 2, 2013.
    28 changes: 28 additions & 0 deletions gistfile1.applescript
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,28 @@
    using terms from application "Messages"
    on message received theMessage from theBuddy for theChat
    tell application "Notifications Scripting"
    -- This is required for calling the user notification event handlers. The handlers can be in a different script file.
    set event handlers script path to (path to me)

    -- The user info parameter is a record. The supported data types are text, integer, real, boolean, date, alias, file and POSIX file.
    set dict to {theName:"Notifications Scripting", theVersion:"1.0", theScript:event handlers script path}

    display notification "New Message" subtitle "From " & (theBuddy's name as string) message "" sound name "Default" user info dict
    end tell
    end message received
    end using terms from

    using terms from application "Notifications Scripting"

    -- This handler is called when a notification was delivered.
    -- All parameters are optionnals.
    on notification delivered title aTitle subtitle aSubTitle message aMessage actual delivery date aDeliveryDate user info aDict
    end notification delivered

    on notification activated title aTitle subtitle aSubTitle message aMessage delivered date aDeliveryDate activation type aType user info aDict
    tell application "System Events"
    tell application "Messages" to activate
    end tell
    end notification activated

    end using terms from