Detect when a User takes a Screenshot

后端 未结 3 1350
死守一世寂寞
死守一世寂寞 2021-01-30 15:26

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.

An e

3条回答
  •  轮回少年
    2021-01-30 15:58

    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.

    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

提交回复
热议问题