积极答复者
WPF 怎么截取屏幕,但不包含本身程序??

问题
答案
-
楼主 你好,
请参考下面的隐藏WPF窗口与截图代码:
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows; using System.Windows.Controls; using System.Windows.Data; using System.Windows.Documents; using System.Windows.Input; using System.Windows.Media; using System.Windows.Media.Imaging; using System.Windows.Navigation; using System.Windows.Shapes; using System.Windows.Forms; using System.Drawing; using System.Drawing.Imaging; namespace WPFScreenshotCapturer { /// <summary> /// Interaction logic for MainWindow.xaml /// </summary> public partial class MainWindow : Window { private static Bitmap bmpScreenshot; private static Graphics gfxScreenshot; public MainWindow() { InitializeComponent(); } private void Button_Click(object sender, RoutedEventArgs e) { this.Hide(); System.Threading.Thread.Sleep(500); // Set the bitmap object to the size of the screen bmpScreenshot = new Bitmap(Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height, System.Drawing.Imaging.PixelFormat.Format32bppArgb); // Create a graphics object from the bitmap gfxScreenshot = Graphics.FromImage(bmpScreenshot); // Take the screenshot from the upper left corner to the right bottom corner gfxScreenshot.CopyFromScreen(Screen.PrimaryScreen.Bounds.X, Screen.PrimaryScreen.Bounds.Y, 0, 0, Screen.PrimaryScreen.Bounds.Size, CopyPixelOperation.SourceCopy); // Save the screenshot to the specified path that the user has chosen bmpScreenshot.Save("D:/Screenshot.png", ImageFormat.Png); this.Show(); } } }
谢谢!We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
Click HERE to participate the survey.- 已标记为答案 heller灬 2014年8月29日 4:05
全部回复
-
楼主 你好,
请参考下面的隐藏WPF窗口与截图代码:
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows; using System.Windows.Controls; using System.Windows.Data; using System.Windows.Documents; using System.Windows.Input; using System.Windows.Media; using System.Windows.Media.Imaging; using System.Windows.Navigation; using System.Windows.Shapes; using System.Windows.Forms; using System.Drawing; using System.Drawing.Imaging; namespace WPFScreenshotCapturer { /// <summary> /// Interaction logic for MainWindow.xaml /// </summary> public partial class MainWindow : Window { private static Bitmap bmpScreenshot; private static Graphics gfxScreenshot; public MainWindow() { InitializeComponent(); } private void Button_Click(object sender, RoutedEventArgs e) { this.Hide(); System.Threading.Thread.Sleep(500); // Set the bitmap object to the size of the screen bmpScreenshot = new Bitmap(Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height, System.Drawing.Imaging.PixelFormat.Format32bppArgb); // Create a graphics object from the bitmap gfxScreenshot = Graphics.FromImage(bmpScreenshot); // Take the screenshot from the upper left corner to the right bottom corner gfxScreenshot.CopyFromScreen(Screen.PrimaryScreen.Bounds.X, Screen.PrimaryScreen.Bounds.Y, 0, 0, Screen.PrimaryScreen.Bounds.Size, CopyPixelOperation.SourceCopy); // Save the screenshot to the specified path that the user has chosen bmpScreenshot.Save("D:/Screenshot.png", ImageFormat.Png); this.Show(); } } }
谢谢!We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
Click HERE to participate the survey.- 已标记为答案 heller灬 2014年8月29日 4:05