C++ Carbon code for capturing Desktop to an image

Discussion in 'Mac Programming' started by soconne, May 27, 2008.

  1. soconne macrumors newbie

    Oct 28, 2007
    Does anybody know how to capture the current desktop screen contents to an image using C++ and Carbon?
  2. psingh01 macrumors 65816

    Apr 19, 2004
    I'm not sure, but I would guess that you can send a key press event and the system will handle it (since shift-apple-3 takes the screenshot already).
  3. Sayer macrumors 6502a


    Jan 4, 2002
    Austin, TX
    If you can use 10.5 use the new CGWindowListCreateImage API.

    Its a procedural C API so you can use it in C++ Carbon apps just fine. There is some sample code from Apple called "SonOfGrab" that shows how to use it, but in a Cocoa context (mostly for dealing with saving the image to a file easier).

Share This Page