I am screen capturing as follows:
Bitmap b = new Bitmap(ScreenWidth, ScreenHeight); g = Graphics.FromImage(b); g.CopyFromScreen(Point.Empty, Point.Empty, Screen.PrimaryScreen.Bounds.Size); b.Save(@"S:\\shot" + i.ToString() + ".jpg", System.Drawing.Imaging.ImageFormat.Jpeg); i = i + 1;
The problem is when I lock the computer, it gives The handle is invalid exception for the line below:
g.CopyFromScreen(Point.Empty, Point.Empty, Screen.PrimaryScreen.Bounds.Size);How can I fix this?
Best Regards.
VulpesPosted Jan 6, 2012, 9:12 AM
A cruder way would be to simply place the code in a 'try' block and catch (and swallow) the exception if the desktop is locked.
RaysefoPosted Jan 6, 2012, 9:47 AM
RaysefoPosted Jan 6, 2012, 9:00 AM