I have these lines of code that takes a screenshot and "gets" it:
SendKeys.Send("{PRTSC}");
Image img = Clipboard.GetImage();
initScreenShot = new Bitmap(img);
But some times i get the error message:
An unhandled exception of type 'System.NullReferenceException' occurred in System.Drawing.dll
on the lineinitScreenShot = new Bitmap(img);
, this happens about 25% of the times i run the code. Why is that?