Screenshoter: Avoid exception while copy screen when there is no desktop.
This commit is contained in:
@@ -1,4 +1,5 @@
|
|||||||
using System.Drawing;
|
using System;
|
||||||
|
using System.Drawing;
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
|
|
||||||
namespace VAR.ScreenAutomation.Code
|
namespace VAR.ScreenAutomation.Code
|
||||||
@@ -29,11 +30,15 @@ namespace VAR.ScreenAutomation.Code
|
|||||||
bmp = new Bitmap(width ?? 0, height ?? 0);
|
bmp = new Bitmap(width ?? 0, height ?? 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
// Draw the screenshot into our bitmap.
|
// Draw the screenshot into our bitmap.
|
||||||
using (Graphics g = Graphics.FromImage(bmp))
|
using (Graphics g = Graphics.FromImage(bmp))
|
||||||
{
|
{
|
||||||
g.CopyFromScreen(left ?? 0, top ?? 0, 0, 0, bmp.Size);
|
g.CopyFromScreen(left ?? 0, top ?? 0, 0, 0, bmp.Size);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
catch (Exception) { /* Nom Nom Nom */}
|
||||||
return bmp;
|
return bmp;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user