/// <summary> /// /// </summary> public void func_截圖_目前視窗() { /* 取得該視窗的大小與位置 */ System.Drawing.Rectangle bounds = new System.Drawing.Rectangle(); GetWindowRect(GetForegroundWindow(), ref bounds); bounds.Width = bounds.Width - bounds.X; bounds.Height = bounds.Height - bounds.Y; var we = new W_sc_effects(); we.Show(); we.func_局部(bounds.X, bounds.Y, bounds.Width, bounds.Height); using (var img = new System.Drawing.Bitmap(bounds.Width, bounds.Height, System.Drawing.Imaging.PixelFormat.Format32bppArgb)) { var gfx = System.Drawing.Graphics.FromImage(img); gfx.CopyFromScreen(bounds.X, bounds.Y, 0, 0, bounds.Size, System.Drawing.CopyPixelOperation.SourceCopy); String s_儲存路徑 = func_取得儲存檔名("png"); img.Save(s_儲存路徑); //自動存入剪貼簿 try { if (checkBox_自動存入剪貼簿.IsChecked.Value) { Clipboard.SetData(DataFormats.Bitmap, img); } } catch { } } }
/// <summary> /// /// </summary> public void func_截圖_全螢幕() { /* if (w_截圖 != null) * return; * w_截圖 = */ new W_截圖(this, e_截圖類型.全螢幕截圖_png); var we = new W_sc_effects(); we.Show(); we.func_全螢幕(); }