Capture screenshot of active window?

Rectangle bounds = Screen.GetBounds(Point.Empty); using(Bitmap bitmap = new Bitmap(bounds.Width, bounds.Height)) { using(Graphics g = Graphics.FromImage(bitmap)) { g.CopyFromScreen(Point.Empty, Point.Empty, bounds.Size); } bitmap.Save(“test.jpg”, ImageFormat.Jpeg); } for capturing current window use Rectangle bounds = this.Bounds; using (Bitmap bitmap = new Bitmap(bounds.Width, bounds.Height)) { using (Graphics g = Graphics.FromImage(bitmap)) { g.CopyFromScreen(new Point(bounds.Left,bounds.Top), Point.Empty, bounds.Size); } bitmap.Save(“C://test.jpg”, ImageFormat.Jpeg); }

Swing: Obtain Image of JFrame

ComponentImageCapture.java import java.awt.BorderLayout; import java.awt.Component; import java.awt.Image; import java.awt.Graphics; import java.awt.image.BufferedImage; import java.awt.event.ActionListener; import java.awt.event.ActionEvent; import java.awt.event.KeyEvent; import java.awt.event.InputEvent; import javax.swing.*; import javax.swing.border.TitledBorder; import javax.imageio.ImageIO; import java.io.File; /** Create a screenshot of a component. @author Andrew Thompson */ class ComponentImageCapture { static final String HELP = “Type Ctrl-0 to get a screenshot of the current … Read more

Website screenshots

LAST EDIT: after 7 years I’m still getting upvotes for this answer, but I guess this one is now much more accurate. Sure you can, but you’ll need to render the page with something. If you really want to only use php, I suggest you HTMLTOPS, which renders the page and outputs it in a … Read more