using System.Drawing;
//打開該頁面
System.Diagnostics.Process.Start("IEXPLORE.EXE", "http://localhost:56/Spacxxe.html");
System.Threading.Thread.Sleep(3000);
//截屏
//創(chuàng)建并設(shè)置畫布大小
System.Drawing.Image templateImage = new System.Drawing.Bitmap(1040, 700);
System.Drawing.Graphics templateG = System.Drawing.Graphics.FromImage(templateImage);
//new Point(200, 100)位于源(屏幕)左上角的x,y坐標(biāo)
//new Point(0, 0)圖片位于畫布左上角的x,y坐標(biāo)
//new Size(1440, 900)所截屏幕的大小
templateG.CopyFromScreen(new Point(200, 100), new Point(0, 0), new Size(1000, 900), CopyPixelOperation.MergeCopy);
//關(guān)閉ie
System.Diagnostics.Process[] pro = System.Diagnostics.Process.GetProcessesByName("IEXPLORE");
foreach (System.Diagnostics.Process ps in pro)
{
ps.Kill();
}
//保存
templateImage.Save(@"E:\TEST\" + imgname + ".jpg", System.Drawing.Imaging.ImageFormat.Jpeg);