Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Determine the source application of current pasteboard content

Several OSX clipboard managers from AppStore show the ability to determine the source-application of content that was copied to the clipboard.

I am writing some simple clipboard observer and would like to show the source-application icon near the content, stored in general NSPasteboard. And I would like to know how this can be achieved.

As far as I can see, NSPasteboard doesn't provide any additional info except types of data and data itself.

Maybe there are some events or notifications to know that a 'copy' command was triggered? Or some other ways?

like image 459
UJey Avatar asked May 01 '13 19:05

UJey


1 Answers

I believe that the way CopyLess and Alfred 2 (which also supports this) work is that they have a timer that checks the clipboard for changes. When they see a change on the clipboard they get the active application and associate that app with the change. It's likely not a foolproof method but should work in most cases.

like image 198
Dustin Avatar answered Nov 23 '22 08:11

Dustin