MacOS – Change Copy and Paste behaviour system-wide

applescriptautomatorcopy/pastemacos

I would like to enhance the global copy/paste behaviour with an additional action. In particular, I often use Growl to display custom notifications. From the command line, I can use the growlnotify executable to display something like this:

$ growlnotify -a "Google Chrome" -m "Text Copied" "Google Chrome"

enter image description here

I'd like to somehow modify the global copy/paste behaviour to create a Growl notification like this no matter where I perform the operation and no matter what I'm copying (text, files, etc.). Is this possible using Automator/AppleScript (I'm only vaguely familiar with AppleScript)? Or something else?

Best Answer

You can use applications like Keyboard Maestro (my preference), FastScripts, Spark to run a script which displays notification every time you press Cmd+C, or Cmd+V. Below is the Copy script which posts notification in Growl. Though you could also post these to OS X notification centre too.

tell application "System Events"
    set foremostApplication to name of first process where it is frontmost
end tell
tell application "Growl"
    register as application "Pasteboard Notifier" all notifications {"Copied", "Pasted"} default notifications {"Copied"}
    notify with name "Copied" title "Copied!" description "New Clipboard Item" application name "Pasteboard Notifier" icon of application foremostApplication
end tell

I tried creating a service through Automator, and binding that to Cmd+C; it didn't seem to work. You'd be better of using a app made to do this kind of work.

Edit: 05/11/15

I noticed that service created via the method above did work in Steam, while not in other Applications. I think because it doesn't have the Edit menu hence no Cut, Copy, and Paste items either. The application shortcuts probably get precedence over services linked to same shortcuts.