如何收听屏幕截图
我是否可以听 OSX 内置的屏幕捕获,这样我就可以自己处理文件而不是 osx 来处理?
Is it possible for me to listen to listen to OSX's built in screencapturing so I can handle the files myself rather than osx doing it?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
有几种选择。
只需使用
Ctrl-Cmd-Shift-3
或4
而不是Cmd-Shift-3
或4
>。这不会将文件保存到桌面,而是将数据保存在剪贴板/粘贴板中。我不知道官方在哪里提到过这一点,但是这里有一个 。然后就可以通过NSPasteboard
获取数据,参见此处。您可以使用
FSEvents
每当在指定文件夹中创建文件时收到通知。然后,您可以在系统将屏幕截图文件保存到桌面后立即对其进行重命名。请注意,屏幕截图的文件名取决于您在系统偏好设置中选择的语言环境。因此,如果您想让程序在非英语机器上运行,请务必小心。如果您只是以编程方式截取屏幕截图,可以使用命令行工具
screencapture
,请参阅手册页。当然,您可以侵入系统并接管
Cmd-Shift-3,4
的处理,例如Snapz Pro
所做的那样。如果您选择这种方式,您就知道自己在做什么。There are a few options.
Just use
Ctrl-Cmd-Shift-3
or4
instead ofCmd-Shift-3
or4
. This does not save the file to the desktop, instead it saves the data in the clipboard/pasteboard. I don't know where's the official mention of this, but here is one. Then you can get the data throughNSPasteboard
, see here.You can use
FSEvents
to be notified whenever a file is created in a specified folder. Then you can rename the screenshot file soon after it was saved to the desktop by the system. Note that the file name of the screenshot depends on the language environment you choose in System Preferences. So, be very careful if you want to make your program work on a non-English machine.If you just programmatically take the screenshot, you can use the command line tool
screencapture
, see the man page.Of course you can hack into the system and take over the handling of
Cmd-Shift-3,4
, asSnapz Pro
does, for example. You know what you're doing if you choose that way.