How do I find a window at a certain point on the screen for screenshot/screen-recording purposes?

a 夏天 提交于 2019-12-01 09:43:15

问题


I'm looking for a way to do what the equivalent of WindowFromPoint and GetWindowRect do, in Carbon/Cocoa and X11.

WindowFromPoint - http://msdn.microsoft.com/en-us/library/ms633558%28VS.85%29.aspx GetWindowRect - http://msdn.microsoft.com/en-us/library/ms633519%28VS.85%29.aspx


回答1:


I am developing screenshot and screen recording apps …

Use Quartz Window Services.

I want to … determine the bounding rectangle of the window, and then use the coordinates of the window to capture a bitmap of that area of the screen …

Definitely use Quartz Window Services.

Incidentally, one of its features is that you can capture a window in isolation, without anything that may be in front of it or behind it. You don't need to get its rectangle when doing this.

… and save it to a file …

Use CGImageDestination.

… or encode it into a video stream.

That part I'm not sure about. The sample code on the matter (which, as its name says, uses OpenGL for the actual capturing) uses the 32-bit-only QuickTime C API, not the 64-bit-compatible QuickTime Kit, to write the movie.




回答2:


To answer the X11 portion of this question: You can use XQueryPointer's child_return for similar functionality to WindowFromPont. XGetGeometry should get you the GetWindowRect information.



来源:https://stackoverflow.com/questions/2869052/how-do-i-find-a-window-at-a-certain-point-on-the-screen-for-screenshot-screen-re

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!