views:

39

answers:

2

I am making a very simple app in C# with Visual Studio, so I'm using that Forms package. I need to get access to an image of everything below it, so that I can manipulate the image. How can I do this?

It doesn't have to be real time very much, since I'll probably be polling it not more than say 10fps.

+1  A: 

You could use Graphics.CopyFromScreen, but you will need to hide your window before you call it or otherwise it will appear in the image.

Zach Johnson
+1  A: 

You can use Interop to get a hook to the "Desktop Window", if that's what you mean, and then you can use that to get your screenshot...this link might help:

Getting the Desktop Window from .NET

Another option (you said WinForms, right) is to create a placeholder Bitmap and use the Graphics.CopyFromScreen method:

int screenWidth = 1024;
int screenHeight = 768;
Bitmap holder = new Bitmap(screenWidth, screenHeight);
Graphics graphics = Graphics.FromImage(holder);
graphics.CopyFromScreen(0,0,0,0,new Size(screenWidth, screenHeight), CopyPixelOperation.SourceCopy);
JerKimball