检测用户何时拍摄屏幕截图 [英] Detect when a User takes a Screenshot

查看:121
本文介绍了检测用户何时拍摄屏幕截图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在寻找一种方法,当用户使用Command-Shift-3Command-Shift-4进行屏幕截图时,我的应用程序会收到通知.

I am looking for way for my app to receive a notification when the user takes a screenshot either with Command-Shift-3 or Command-Shift-4.

例如Droplr和Cloud App之类的应用程序会自动上传所拍摄的屏幕截图.

An example of this are apps like Droplr and Cloud App which automatically upload the screenshot taken.

我一直在搜索,发现它可能与达尔文通知"有关,但是我不确定从哪里开始.

I have been searching around and found out that it may have something to do with Darwin Notifications but I am unsure as to where to start.

推荐答案

在前面的注释之一中提到了此问题,但是您可以使用NSMetadataQuerykMDItemIsScreenCapture = 1中搜索文件.这是一个特殊属性,已添加到屏幕截图文件中.

This was mentioned in one of the earlier comments, but you can use an NSMetadataQuery searching for files where kMDItemIsScreenCapture = 1. This is a special attribute that gets added to screenshot files.

我刚刚整理了一个演示如何执行此操作的演示并将其发布在github上:

I just whipped up a little demo showing how to do this and posted it on github:

https://github.com/davedelong/Demos/blob/master/ScreenShot%20Detector

这篇关于检测用户何时拍摄屏幕截图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆