2

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

ThinkingStiff
  • 64,767
  • 30
  • 146
  • 239
Jake Petroules
  • 23,472
  • 35
  • 144
  • 225
  • 1
    http://stackoverflow.com/questions/2628921/find-window-at-location-using-carbon-and-carbon-problems-in-64-bit-applications –  May 19 '10 at 20:51
  • What do you intend to do with the retrieved window "handle". The window manager on carbon/cocoa keeps a lot of data structures per-process for windows so the only real way to get meaningful access to another window on OS X is via the accessibility apis. – Chris Becke May 20 '10 at 07:22
  • Well, I am developing screenshot and screen recording apps - I want to use the handle 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 and save it to a file or encode it into a video stream. – Jake Petroules May 20 '10 at 18:29

2 Answers2

4

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.

Peter Hosey
  • 95,783
  • 15
  • 211
  • 370
1

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.

Alex Barker
  • 4,316
  • 4
  • 28
  • 47