5

I'm facing a problem when my application needs to get screenshots of other Windows applications.

I'm using the function in win32api 'PrintWindow', but this doesn't work well. It is slow and some components inside other applications' windows shown as black rectangles.

There is an application (Mac-OS-style task switcher) called DExpose2 by Devrexster. It can get the screenshots of other applications really fast, damn fast, even it can get these screenshots continuously.

I guess it is using Direct3D to get screenshots of applications instead of using GDI as I'm using. Is it possible to to use Direct3D for this purpose? and if possible, which should be the neatest way?

2 Answers 2

4

The answer for Vista+ is in another answer : snoop on DirectX's buffer.

DExpose2 probably doesn't "get" the screenshots. I.e. it doesn't transfer them from the videocard to RAM. That's a slow operation, and would have to be followed by another slow copy back to the videocard. I expect that it just applies a few scale and move transforms on the videocard side, with no pixels or texels crossing the PCI-e bus.

2

You can use bitblt to get a screenshot. Here's an example of getting it for the entire desktop:

http://msdn.microsoft.com/en-us/library/windows/desktop/dd183402(v=vs.85).aspx

You probably need to adjust the X, Y, and size parameters so that you get a subset, corresponding to just the window you care about.

1
  • that might work. however, from windows vista onward, seems like we have new functions in the winapi using direct3d or something
    – jondinham
    Jan 3, 2013 at 5:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.