views:

655

answers:

4

Hi! I want to print the screen (not with the printer) I want to print it like the 'print button' on the keyboard and get an image. Any idea? I did have no starting point :(

A: 

Hi,

There are several articles I've found may help you.

Please check them.

Capturing the Screen Image Using C#

Braveyard
Ehm, your first link just points to the forum message that points to the second link :P
Max
ehm, thanks I forgot that :P
Braveyard
+15  A: 

If using the .NET 2.0 (or later) framework you can use the CopyFromScreen() method detailed here:

http://www.geekpedia.com/tutorial181_Capturing-screenshots-using-Csharp.html

//Create a new bitmap.
bmpScreenshot = new Bitmap(Screen.PrimaryScreen.Bounds.Width,
                           Screen.PrimaryScreen.Bounds.Height,
                           PixelFormat.Format32bppArgb);

// Create a graphics object from the bitmap.
gfxScreenshot = Graphics.FromImage(bmpScreenshot);

// Take the screenshot from the upper left corner to the right bottom corner.
gfxScreenshot.CopyFromScreen(Screen.PrimaryScreen.Bounds.X,
                            Screen.PrimaryScreen.Bounds.Y,
                            0,
                            0,
                            Screen.PrimaryScreen.Bounds.Size,
                            CopyPixelOperation.SourceCopy);

// Save the screenshot to the specified path that the user has chosen.
bmpScreenshot.Save("Screenshot.png", ImageFormat.Png);
Gary Willoughby
Nice and simple ... works like a charm ... thanks!
Edward Leno
A: 

Here is a similar post: how-can-i-save-screenshot-directly-to-a-file-in-windows.

The code is with win32 calls. Gary code is good too. Simply two different way to do it :)

Daok
A: 

You can play around with SendKeys and get the behavior you want as well.

SendKeys PrtScrn for the full screen.

SendKeys Alt+PrntScrn for the current window only.

Access the Clipboard for the image. (You may want to save anything already on the clipboard prior to using SendKeys and put whatever was on there back when you're done.)

Austin Salonen
Good idea I'll give it a try, hope it's easy to deal with the clipboard
Omar Abid