确定当前粘贴板内容的源应用程序 [英] Determine the source application of current pasteboard content
问题描述
来自AppStore的几个OSX剪贴板管理器显示了确定复制到剪贴板的内容的源应用程序的功能。
Several OSX clipboard managers from AppStore show the ability to determine the source-application of content that was copied to the clipboard.
我正在写一些简单的剪贴板观察器和想要在内容附近显示源应用程序图标,存储在一般的NSPasteboard中。我想知道如何实现这一点。
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.
据我所见,NSPasteboard不提供任何额外的信息,除了数据类型和数据本身。
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?
推荐答案
我相信CopyLess和Alfred 2一个检查剪贴板的更改的计时器。当他们在剪贴板上看到一个变化时,他们得到活跃的应用程序和关联该应用程序的变化。这可能不是一个万无一失的方法,但在大多数情况下应该可以工作。
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.
这篇关于确定当前粘贴板内容的源应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!