c# - Capture the screen shot using .NET -


possible duplicate:
how may capture screen in bitmap?

i need make application captures snapshot of current screen whenever particular button hit.

i have searched lot, have found how capture current window.

can please me figure out how in .net?

we can manually hitting print-screen , saving image using paint. need same thing, want program.

it's possible grab screenshot using .net framework. simplest way create new bitmap object , draw using graphics.copyfromscreen method.

sample code:

using (bitmap bmpscreencapture = new bitmap(screen.primaryscreen.bounds.width,                                              screen.primaryscreen.bounds.height)) {     using (graphics g = graphics.fromimage(bmpscreencapture))     {         g.copyfromscreen(screen.primaryscreen.bounds.x,                          screen.primaryscreen.bounds.y,                          0, 0,                          bmpscreencapture.size,                          copypixeloperation.sourcecopy);     } } 

caveat: method doesn't work layered windows. hans passant's answer here explains more complicated method required in screen shots.


Comments

Popular posts from this blog

apache - Add omitted ? to URLs -

redirect - bbPress Forum - rewrite to wwww.mysite prohibits login -

php - How can I stop spam on my custom forum/blog? -