From b8ca44d14c7e791a3338398af997bda05abf336a Mon Sep 17 00:00:00 2001 From: Gavin Kendall Date: Mon, 8 Mar 2021 12:53:04 -0500 Subject: [PATCH] 2.3.4.1 - Does not capture image of screen if screen does not exist. --- Properties/AssemblyInfo.cs | 4 ++-- ScreenCapture.cs | 21 ++++++++++++--------- app.manifest | 2 +- changelog.txt | 1 + interface/FormAbout.resx | 3 ++- modules/regions/FormRegion.cs | 2 ++ modules/screens/FormScreen.cs | 14 ++++++++------ 7 files changed, 28 insertions(+), 19 deletions(-) diff --git a/Properties/AssemblyInfo.cs b/Properties/AssemblyInfo.cs index 7eeb3fc9..eba3563e 100644 --- a/Properties/AssemblyInfo.cs +++ b/Properties/AssemblyInfo.cs @@ -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")] \ No newline at end of file diff --git a/ScreenCapture.cs b/ScreenCapture.cs index 426f094d..4e7a9ad5 100644 --- a/ScreenCapture.cs +++ b/ScreenCapture.cs @@ -439,18 +439,27 @@ public Image GetImageByPath(string path) /// /// Gets the bitmap image of the screen based on X, Y, Width, and Height. This is used by Screens and Regions. /// + /// The source. + /// The component of the source. /// The X value of the bitmap. /// The Y value of the bitmap. /// The Width value of the bitmap. /// The Height value of the bitmap. /// Determines if the mouse pointer should be included in the bitmap. /// A bitmap image representing what we captured. - 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); @@ -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; @@ -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) { diff --git a/app.manifest b/app.manifest index 2343d21e..e6f49fec 100644 --- a/app.manifest +++ b/app.manifest @@ -3,7 +3,7 @@ + version="2.3.4.1"/> True/PM diff --git a/changelog.txt b/changelog.txt index a20ecb99..45876759 100644 --- a/changelog.txt +++ b/changelog.txt @@ -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. diff --git a/interface/FormAbout.resx b/interface/FormAbout.resx index bb590558..417f5177 100644 --- a/interface/FormAbout.resx +++ b/interface/FormAbout.resx @@ -118,7 +118,7 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - Auto Screen Capture 2.3.4.0 ("Boombayah") + Auto Screen Capture 2.3.4.1 ("Boombayah") Developed by Gavin Kendall (2008 - 2021) SourceForge Project Site @@ -140,6 +140,7 @@ Triggers have been rewritten. I haven't spent much time on the new wizard-style 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. diff --git a/modules/regions/FormRegion.cs b/modules/regions/FormRegion.cs index 7632f1a5..4de28200 100644 --- a/modules/regions/FormRegion.cs +++ b/modules/regions/FormRegion.cs @@ -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, diff --git a/modules/screens/FormScreen.cs b/modules/screens/FormScreen.cs index 708464d9..7326c3d6 100644 --- a/modules/screens/FormScreen.cs +++ b/modules/screens/FormScreen.cs @@ -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();