在C#中,在控件外的的鼠标点击是无法获取的。于是,这里采用了新建窗口,覆盖整个屏幕,并设置不透明度,从而从新的窗口中获取到鼠标点击的点,然后传回截图的参数当中。截图的代码如下,并设置绘制文字的内容。
private void GetFullImage()
{
Screen scr = Screen.PrimaryScreen;
Rectangle rc = scr.Bounds;
int iWidth = rc.Width;
int iHeight = rc.Height;
Image myImage = new Bitmap(iWidth, iHeight);
Graphics g = Graphics.FromImage(myImage);
g.CopyFromScreen(new Point(0, 0), new Point(0, 0), new Size(iWidth, iHeight));
String str = "hello, string";
Font font = new Font("宋体", 8);
SolidBrush sbrush = new SolidBrush(Color.Red);
g.DrawString(str, font, sbrush, new PointF(600, 200));
myImage.Save(this.FilePath.Text + this.FilePre.Text + count + ".jpeg");
}
private void GetPartImage()
{
int iWidth = Math.Abs(end.X - start.X);
int iHeight =