在 Mac OS X 桌面上选择一个区域
如果在 Mac OS X 中按 cmd+shift+4,您可以选择屏幕上的一个区域,并显示相应的坐标。 我需要在我的一个应用程序中实现这样的功能,但不知道如何执行。 有人可以给我一些建议吗?
谢谢。
If you press cmd+shift+4 in Mac OS X you are able to select an area on your screen with the corrosponding coordinates shown. I need to implement such a function in one of my applications and have no idea of how to do it. Could anyone give me some advices on that?
Thx.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
此代码片段将返回一个 CGImageRef,其中包含给定矩形的桌面上显示的所有内容。 它需要 ApplicationServices 框架。 屏幕坐标翻转,原点位于屏幕左上角。 在这种情况下,图像引用将由调用者拥有,并且需要在调用者完成使用后使用 CGImageRelease 进行释放。
This code fragment will return a CGImageRef that contains everything shown on the desktop for a given rectangle. It requires the ApplicationServices framework. The screen coordinates are flipped and the origin is at the top-left corner of the screen. In this case, the image ref would be owned by the caller and would need to be released with
CGImageRelease
when the caller was finished with it.通常,这是通过覆盖整个桌面空间的半透明覆盖窗口来完成的。
Apple 提供了一些较旧的示例代码,应该可以帮助您入门。
Typically this is done with an translucent overlay window which covers the entire desktop space.
Apple's got some older sample code which should give you a start.