Skip to content

Instantly share code, notes, and snippets.

@apcomplete
Created October 2, 2013 20:26
Show Gist options
  • Save apcomplete/6800017 to your computer and use it in GitHub Desktop.
Save apcomplete/6800017 to your computer and use it in GitHub Desktop.
AppleScript for displaying OSX notifications when receiving a message in Messages without displaying the message text in the notification.
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment