屏幕捕获桌面的目标区域

我正在尝试在C#中重新创建一个Winform应用程序,它具有与剪切工具窗口提供的function相同的function。 也就是说,允许用户在桌面上拖动一个矩形并捕获内部的图像。

目前我只能用鼠标绘制一个矩形,并且在winform中。 任何人都可以指出我如何做到这一点,所以我可以在整个桌面内做到这一点?

我绘制矩形的代码如下:

Rectangle rect; public Form1() { InitializeComponent(); // set the cursor to be a + sign this.Cursor = System.Windows.Forms.Cursors.Cross; this.DoubleBuffered = true; } private void Form1_MouseDown(object sender, MouseEventArgs e) { // eX and eY are used to get the X and Y pos of the mouse rect = new Rectangle(eX, eY, 0, 0); this.Invalidate(); } private void Form1_MouseMove(object sender, MouseEventArgs e) { if (e.Button == MouseButtons.Left) { // draw rectangle as mouse moves rect = new Rectangle(rect.Left,rect.Top, eX - rect.Left, eY - rect.Top); } this.Invalidate(); } private void Form1_Paint(object sender, PaintEventArgs e) { // Replace "Color.Red" with any color and repalce "2" with any size you like. using (Pen pen = new Pen(Color.Red, 2)) { e.Graphics.DrawRectangle(pen, rect); } } } 

我一直在网上搜索,但我的搜索还没有提供任何使用。

任何帮助将不胜感激。

请参阅: http : //everysolutionshere.blogspot.in/2014/01/how-to-capture-screen-in-c.html

我希望它对你有所帮助。