Screenshot of another app's Window

  • Hi,

    I'm trying to get a screenshot of another app's window, if that's
    possible, from within my cocoa app. So this is somewhat of a multipart
    question:

    1.) How can I get a list of open windows and check to see if the
    window I am looking for is there?
    2.) How do I make sure this window is frontmost? How do I make it frontmost?
    3.) What functions must I use to take a screenshot of a specific rect?

    Thank you very much, I've been searching around on google and it
    hasn't been bringing much up.

    Mitchell Hashimoto
  • On Jun 29, 2007, at 11:08 AM, Mitchell Hashimoto wrote:

    > Hi,
    >
    > I'm trying to get a screenshot of another app's window, if that's
    > possible, from within my cocoa app. So this is somewhat of a multipart
    > question:
    >
    > 1.) How can I get a list of open windows and check to see if the
    > window I am looking for is there?
    > 2.) How do I make sure this window is frontmost? How do I make it
    > frontmost?
    > 3.) What functions must I use to take a screenshot of a specific rect?
    >
    > Thank you very much, I've been searching around on google and it
    > hasn't been bringing much up.
    >
    > Mitchell Hashimoto

    Starting in Mac OS X 10.5 On Mac OS X 10.5 you can read back
    information on other windows within the same GUI session as the
    calling process using the CGWindow API (defined in /System/Library/
    Frameworks/ApplicationServices.framework/Frameworks/
    CoreGraphics.framework/Headers/CGWindow.h).

    Windows which have been marked as shared (kCGWindowSharingReadOnly,
    the default, or kCGWindowSharingReadWrite) can be captured as
    CGImageRefs.

    Images can be generated from a list of windows passed to
    CGWindowListCreateImageFromArray(),  or from a set of selection
    conditions ("All windows below this window") passed to
    CGWindowListCreateImage().  Various options control the bounds and
    content of the resulting image.

    Refer to the comments in the header file for information on using
    these new APIs.

    Mike Paquette
    CoreGraphics Team
previous month june 2007 next month
MTWTFSS
        1 2 3
4 5 6 7 8 9 10
11 12 13 14 15 16 17
18 19 20 21 22 23 24
25 26 27 28 29 30  
Go to today