diff --git a/Properties/AssemblyInfo.cs b/Properties/AssemblyInfo.cs index 5be75394..f631c23a 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.3")] -[assembly: AssemblyFileVersion("2.3.4.3")] +[assembly: AssemblyVersion("2.3.4.4")] +[assembly: AssemblyFileVersion("2.3.4.4")] [assembly: NeutralResourcesLanguageAttribute("en-CA")] \ No newline at end of file diff --git a/ScreenCapture.cs b/ScreenCapture.cs index 361f3e78..2a388dcb 100644 --- a/ScreenCapture.cs +++ b/ScreenCapture.cs @@ -449,55 +449,55 @@ public Image GetImageByPath(string path) /// A bitmap image representing what we captured. public Bitmap GetScreenBitmap(int source, int component, int x, int y, int width, int height, bool mouse) { - try + if (width > 0 && height > 0) { - if (width > 0 && height > 0) + if (source > 0 && component > -1) { - if (source > 0 && component > -1) + try { // 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]; } + catch + { + return null; + } + } - Size blockRegionSize = new Size(width, height); + Size blockRegionSize = new Size(width, height); - Bitmap bmp = new Bitmap(width, height); + Bitmap bmp = new Bitmap(width, height); - using (Graphics g = Graphics.FromImage(bmp)) + using (Graphics g = Graphics.FromImage(bmp)) + { + g.CopyFromScreen(x, y, 0, 0, blockRegionSize, CopyPixelOperation.SourceCopy); + + if (mouse) { - g.CopyFromScreen(x, y, 0, 0, blockRegionSize, CopyPixelOperation.SourceCopy); + CURSORINFO pci; + pci.cbSize = Marshal.SizeOf(typeof(CURSORINFO)); - if (mouse) + if (GetCursorInfo(out pci)) { - CURSORINFO pci; - pci.cbSize = Marshal.SizeOf(typeof(CURSORINFO)); - - if (GetCursorInfo(out pci)) + if (pci.flags == CURSOR_SHOWING) { - if (pci.flags == CURSOR_SHOWING) - { - var hdc = g.GetHdc(); - DrawIconEx(hdc, pci.ptScreenPos.x - x, pci.ptScreenPos.y - y, pci.hCursor, 0, 0, 0, IntPtr.Zero, DI_NORMAL); - g.ReleaseHdc(); - } + var hdc = g.GetHdc(); + DrawIconEx(hdc, pci.ptScreenPos.x - x, pci.ptScreenPos.y - y, pci.hCursor, 0, 0, 0, IntPtr.Zero, DI_NORMAL); + g.ReleaseHdc(); } } } - - CaptureError = false; - - return bmp; } - CaptureError = true; + CaptureError = false; - return null; - } - catch - { - return null; + return bmp; } + + CaptureError = true; + + return null; } /// @@ -619,19 +619,17 @@ public bool GetScreenImages(int source, int component, int x, int y, int width, { try { + CaptureError = false; + bitmap = source == 0 && component == 0 ? GetActiveWindowBitmap() : GetScreenBitmap(source, component, x, y, width, height, mouse); if (bitmap != null) { - CaptureError = false; - return true; } - CaptureError = true; - return false; } catch (Exception ex) diff --git a/app.manifest b/app.manifest index 81dbff95..de6f332c 100644 --- a/app.manifest +++ b/app.manifest @@ -3,7 +3,7 @@ + version="2.3.4.4"/> True/PM diff --git a/changelog.txt b/changelog.txt index 28b717a3..83a91aef 100644 --- a/changelog.txt +++ b/changelog.txt @@ -4,6 +4,7 @@ Auto Screen Capture by Gavin Kendall Codename "Boombayah" +2.3.4.4 Fix to Screen Capture method. 2.3.4.3 Fix to Screen Capture method. 2.3.4.2 Fix to Screen form for preview image. 2.3.4.1 Does not capture image of screen if screen does not exist. diff --git a/interface/FormAbout.resx b/interface/FormAbout.resx index 826c14d6..2f56fbda 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.3 ("Boombayah") + Auto Screen Capture 2.3.4.34 ("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.4 Fix to Screen Capture method. 2.3.4.3 Fix to Screen Capture method. 2.3.4.2 Fix to Screen form for preview image. 2.3.4.1 Does not capture image of screen if screen does not exist. diff --git a/settings/Settings.cs b/settings/Settings.cs index 5dd51f04..707ff1c0 100644 --- a/settings/Settings.cs +++ b/settings/Settings.cs @@ -222,6 +222,7 @@ public void Load(FileSystem fileSystem) _versionCollection.Add(new Version(CODENAME_BOOMBAYAH, "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. _versionCollection.Add(new Version(CODENAME_BOOMBAYAH, "2.3.4.1")); // Does not capture image of screen if screen does not exist. _versionCollection.Add(new Version(CODENAME_BOOMBAYAH, "2.3.4.2")); // Fix to Screen form for preview image. + _versionCollection.Add(new Version(CODENAME_BOOMBAYAH, "2.3.4.3")); // Fix to Screen form for preview image. Application = new SettingCollection() {