Skip to content

Commit

Permalink
2.3.4.1 - Does not capture image of screen if screen does not exist.
Browse files Browse the repository at this point in the history
  • Loading branch information
gavinkendall committed Mar 8, 2021
1 parent 90bae94 commit b8ca44d
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 19 deletions.
4 changes: 2 additions & 2 deletions Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,6 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("2.3.4.0")]
[assembly: AssemblyFileVersion("2.3.4.0")]
[assembly: AssemblyVersion("2.3.4.1")]
[assembly: AssemblyFileVersion("2.3.4.1")]
[assembly: NeutralResourcesLanguageAttribute("en-CA")]
21 changes: 12 additions & 9 deletions ScreenCapture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -439,18 +439,27 @@ public Image GetImageByPath(string path)
/// <summary>
/// Gets the bitmap image of the screen based on X, Y, Width, and Height. This is used by Screens and Regions.
/// </summary>
/// <param name="source">The source.</param>
/// <param name="component">The component of the source.</param>
/// <param name="x">The X value of the bitmap.</param>
/// <param name="y">The Y value of the bitmap.</param>
/// <param name="width">The Width value of the bitmap.</param>
/// <param name="height">The Height value of the bitmap.</param>
/// <param name="mouse">Determines if the mouse pointer should be included in the bitmap.</param>
/// <returns>A bitmap image representing what we captured.</returns>
public Bitmap GetScreenBitmap(int x, int y, int width, int height, bool mouse)
public Bitmap GetScreenBitmap(int source, int component, int x, int y, int width, int height, bool mouse)
{
try
{
if (width > 0 && height > 0)
{
if (source > 0 && component > -1)
{
// Test if we can acquire the actual screen from Windows and if we can't just let this
// method catch the out of bounds exception error.
System.Windows.Forms.Screen screen = System.Windows.Forms.Screen.AllScreens[component];
}

Size blockRegionSize = new Size(width, height);

Bitmap bmp = new Bitmap(width, height);
Expand Down Expand Up @@ -485,14 +494,8 @@ public Bitmap GetScreenBitmap(int x, int y, int width, int height, bool mouse)

return null;
}
catch (Exception ex)
catch
{
// Don't log an error if Windows is locked at the time a screenshot was taken.
if (!ex.Message.Equals("The handle is invalid"))
{
_log.WriteExceptionMessage("ScreenCapture::GetScreenBitmap", ex);
}

CaptureError = true;

return null;
Expand Down Expand Up @@ -620,7 +623,7 @@ public bool GetScreenImages(int source, int component, int x, int y, int width,
{
bitmap = source == 0 && component == 0
? GetActiveWindowBitmap()
: GetScreenBitmap(x, y, width, height, mouse);
: GetScreenBitmap(source, component, x, y, width, height, mouse);

if (bitmap != null)
{
Expand Down
2 changes: 1 addition & 1 deletion app.manifest
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<assemblyIdentity
type="win32"
name="GavinKendall.AutoScreenCapture"
version="2.3.4.0"/>
version="2.3.4.1"/>
<asmv3:application>
<asmv3:windowsSettings xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">
<dpiAware>True/PM</dpiAware>
Expand Down
1 change: 1 addition & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ Auto Screen Capture by Gavin Kendall


Codename "Boombayah"
2.3.4.1 Does not capture image of screen if screen does not exist.
2.3.4.0 Screenshots can be sent to a file server either from the main interface window or with a Trigger. The SMTP and SFTP settings are in their own XML files and can be configured. Help system is available but still early in development.
2.3.3.9 Dashboard introduced so you can have an overview of all screens and regions.
2.3.3.8 Screen now has Source (such as Graphics Card and Operating System), X, Y, Width, and Height. Removed "Resolution Ratio" option for better screen capture performance. Removed internal screen dictionary refresh from Windows because we now use X, Y, Width, and Height either from Graphics Card or from Operating System and these values can now be adjusted. Module tab page layout style changed to be multi-line. Refactored code to reduce usage of static classes and static variables for better memory management. Removed calls to GC Collect. Changed screen capture method. "Region Select / Auto Save" region is no longer created when application initialized. "Region Select / Auto Save" screenshots are now shown in all screenshot tabs.
Expand Down
3 changes: 2 additions & 1 deletion interface/FormAbout.resx
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<data name="richTextBoxApplication.Text" xml:space="preserve">
<value>Auto Screen Capture 2.3.4.0 ("Boombayah")
<value>Auto Screen Capture 2.3.4.1 ("Boombayah")
Developed by Gavin Kendall (2008 - 2021)

SourceForge Project Site
Expand All @@ -140,6 +140,7 @@ Triggers have been rewritten. I haven't spent much time on the new wizard-style
</data>
<data name="richTextBoxChangelog.Text" xml:space="preserve">
<value>Codename "Boombayah"
2.3.4.1 Does not capture image of screen if screen does not exist.
2.3.4.0 Screenshots can be sent to a file server either from the main interface window or with a Trigger. The SMTP and SFTP settings are in their own XML files and can be configured. Help system is available but still early in development.
2.3.3.9 Dashboard introduced so you can have an overview of all screens and regions.
2.3.3.8 Screen now has Source (such as Graphics Card and Operating System), X, Y, Width, and Height. Removed "Resolution Ratio" option for better screen capture performance. Removed internal screen dictionary refresh from Windows because we now use X, Y, Width, and Height either from Graphics Card or from Operating System and these values can now be adjusted. Module tab page layout style changed to be multi-line. Refactored code to reduce usage of static classes and static variables for better memory management. Removed calls to GC Collect. Changed screen capture method. "Region Select / Auto Save" region is no longer created when application initialized. "Region Select / Auto Save" screenshots are now shown in all screenshot tabs.
Expand Down
2 changes: 2 additions & 0 deletions modules/regions/FormRegion.cs
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,8 @@ private void UpdatePreviewImage(ScreenCapture screenCapture)
if (checkBoxActive.Checked)
{
pictureBoxPreview.Image = screenCapture.GetScreenBitmap(
-1,
-1,
(int)numericUpDownX.Value,
(int)numericUpDownY.Value,
(int)numericUpDownWidth.Value,
Expand Down
14 changes: 8 additions & 6 deletions modules/screens/FormScreen.cs
Original file line number Diff line number Diff line change
Expand Up @@ -376,12 +376,14 @@ private void UpdatePreviewImage(ScreenCapture screenCapture)
else
{
pictureBoxPreview.Image = screenCapture.GetScreenBitmap(
(int)numericUpDownX.Value,
(int)numericUpDownY.Value,
(int)numericUpDownWidth.Value,
(int)numericUpDownHeight.Value,
checkBoxMouse.Checked
);
comboBoxScreenSource.SelectedIndex,
comboBoxScreenComponent.SelectedIndex,
(int)numericUpDownX.Value,
(int)numericUpDownY.Value,
(int)numericUpDownWidth.Value,
(int)numericUpDownHeight.Value,
checkBoxMouse.Checked
);
}

UpdatePreviewMacro();
Expand Down

0 comments on commit b8ca44d

Please sign in to comment.