最近在討論區看到有人問到這個問題...小弟去找了一下資料..並做一個demo範例分享給大家呀..
此功能主要是可以定時截取螢幕畫面,另存圖片,當按start時開始截圖,視窗會最小化
當還原視窗時會停止截取...
c#(部分程式碼),只要拉兩個控制項button,timer
記得要在C槽底下建一個temp來儲存圖片
public partial class screenshots : Form { private static Bitmap bmpScreenshot; private static Graphics gfxScreenshot; public screenshots() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { this.WindowState = FormWindowState.Minimized; timer1.Enabled = true; } private void timer1_Tick(object sender, EventArgs e) { if (this.WindowState == FormWindowState.Minimized) { bmpScreenshot = new Bitmap(Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height, System.Drawing.Imaging.PixelFormat.Format32bppArgb); gfxScreenshot = Graphics.FromImage(bmpScreenshot); gfxScreenshot.CopyFromScreen(Screen.PrimaryScreen.Bounds.X, Screen.PrimaryScreen.Bounds.Y, 0, 0, Screen.PrimaryScreen.Bounds.Size, CopyPixelOperation.SourceCopy); bmpScreenshot.Save(string.Format(@"c:\temp\{0}.jpg", DateTime.Now.Ticks.ToString()), System.Drawing.Imaging.ImageFormat.Png); } } }
執行結果:
參考網址:
http://www.geekpedia.com/tutorial181_Capturing-screenshots-using-Csharp.htmlhttp://www.blueshop.com.tw/board/show.asp?subcde=BRD20080821135850RHQ&fumcde=FUM20050124191756KKC
# re: [C#]WinForm自動定時截取螢幕畫面,並存成圖片檔, Posted by Lider on 2009/8/14 下午 06:17 回覆
版主您好請問這個是每秒截圖多少次呢? 謝謝。
# re: [C#]WinForm自動定時截取螢幕畫面,並存成圖片檔, Posted by puma on 2009/8/29 上午 10:13 回覆
to Lider,
依Timer 的設定 , 設定1 秒就1秒截圖一次..