diff --git a/Properties/AssemblyInfo.cs b/Properties/AssemblyInfo.cs index 86dc2863..27702b15 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.3.6")] -[assembly: AssemblyFileVersion("2.3.3.6")] +[assembly: AssemblyVersion("2.3.3.7")] +[assembly: AssemblyFileVersion("2.3.3.7")] [assembly: NeutralResourcesLanguageAttribute("en-CA")] \ No newline at end of file diff --git a/ScreenCapture.cs b/ScreenCapture.cs index cd6d49c1..bb85ed8b 100644 --- a/ScreenCapture.cs +++ b/ScreenCapture.cs @@ -39,8 +39,8 @@ public class ScreenCapture [StructLayout(LayoutKind.Sequential)] private struct CURSORINFO { - public Int32 cbSize; - public Int32 flags; + public int cbSize; + public int flags; public IntPtr hCursor; public POINTAPI ptScreenPos; } @@ -70,8 +70,8 @@ private struct POINTAPI [DllImport("user32.dll", SetLastError = true)] private static extern bool DrawIconEx(IntPtr hdc, int xLeft, int yTop, IntPtr hIcon, int cxWidth, int cyHeight, int istepIfAniCur, IntPtr hbrFlickerFreeDraw, int diFlags); - private const Int32 CURSOR_SHOWING = 0x0001; - private const Int32 DI_NORMAL = 0x0003; + private const int CURSOR_SHOWING = 0x0001; + private const int DI_NORMAL = 0x0003; [DllImport("user32.dll")] private static extern bool SetForegroundWindow(IntPtr hWnd); @@ -103,56 +103,56 @@ internal struct WINDOWPLACEMENT public int length; public int flags; public ShowWindowCommands showCmd; - public System.Drawing.Point ptMinPosition; - public System.Drawing.Point ptMaxPosition; - public System.Drawing.Rectangle rcNormalPosition; + public Point ptMinPosition; + public Point ptMaxPosition; + public Rectangle rcNormalPosition; } [DllImport("user32.dll")] private static extern bool ShowWindowAsync(IntPtr hWnd, int nCmdShow); - public const int ENUM_CURRENT_SETTINGS = -1; + private const int ENUM_CURRENT_SETTINGS = -1; [DllImport("user32.dll")] - public static extern bool EnumDisplaySettings(string lpszDeviceName, int iModeNum, ref DEVMODE lpDevMode); + private static extern bool EnumDisplaySettings(string lpszDeviceName, int iModeNum, ref DEVMODE lpDevMode); [StructLayout(LayoutKind.Sequential)] - public struct DEVMODE + private struct DEVMODE { private const int CCHDEVICENAME = 0x20; private const int CCHFORMNAME = 0x20; [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 0x20)] - public string dmDeviceName; - public short dmSpecVersion; - public short dmDriverVersion; - public short dmSize; - public short dmDriverExtra; - public int dmFields; - public int dmPositionX; - public int dmPositionY; - public ScreenOrientation dmDisplayOrientation; - public int dmDisplayFixedOutput; - public short dmColor; - public short dmDuplex; - public short dmYResolution; - public short dmTTOption; - public short dmCollate; + private string dmDeviceName; + private short dmSpecVersion; + private short dmDriverVersion; + internal short dmSize; + private short dmDriverExtra; + private int dmFields; + private int dmPositionX; + private int dmPositionY; + private ScreenOrientation dmDisplayOrientation; + private int dmDisplayFixedOutput; + private short dmColor; + private short dmDuplex; + private short dmYResolution; + private short dmTTOption; + private short dmCollate; [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 0x20)] - public string dmFormName; - public short dmLogPixels; - public int dmBitsPerPel; - public int dmPelsWidth; - public int dmPelsHeight; - public int dmDisplayFlags; - public int dmDisplayFrequency; - public int dmICMMethod; - public int dmICMIntent; - public int dmMediaType; - public int dmDitherType; - public int dmReserved1; - public int dmReserved2; - public int dmPanningWidth; - public int dmPanningHeight; + private string dmFormName; + private short dmLogPixels; + private int dmBitsPerPel; + internal int dmPelsWidth; + internal int dmPelsHeight; + private int dmDisplayFlags; + private int dmDisplayFrequency; + private int dmICMMethod; + private int dmICMIntent; + private int dmMediaType; + private int dmDitherType; + private int dmReserved1; + private int dmReserved2; + private int dmPanningWidth; + private int dmPanningHeight; } /// @@ -356,12 +356,16 @@ private void SaveToFile(string path, ImageFormat format, int jpegQuality, Bitmap bitmap.Save(path, format.Format); } + bitmap.Dispose(); + Log.WriteMessage("Screenshot saved to file at path \"" + path + "\""); } } - catch (Exception ex) + catch (Exception) { - Log.WriteExceptionMessage("ScreenCapture::SaveToFile", ex); + // We want to write to the error file instead of writing an exception just in case the user + // has ExitOnError set and the exception causes the application to exit. + Log.WriteErrorMessage("There was an error encountered when saving the screenshot image."); } } @@ -372,8 +376,11 @@ private void SaveToFile(string path, ImageFormat format, int jpegQuality, Bitmap /// A struct having the screen, display device width, and display device height. public static DeviceResolution GetDeviceResolution(System.Windows.Forms.Screen screen) { - DEVMODE dm = new DEVMODE(); - dm.dmSize = (short)Marshal.SizeOf(typeof(DEVMODE)); + DEVMODE dm = new DEVMODE + { + dmSize = (short)Marshal.SizeOf(typeof(DEVMODE)) + }; + EnumDisplaySettings(screen.DeviceName, ENUM_CURRENT_SETTINGS, ref dm); DeviceResolution deviceResolution = new DeviceResolution() @@ -478,7 +485,7 @@ public Bitmap GetScreenBitmap(int x, int y, int width, int height, int resolutio graphicsDestination.Flush(); CaptureError = false; - + return bitmapDestination; } @@ -613,7 +620,7 @@ public string GetActiveWindowProcessName() /// /// Gets the bitmap images for the avaialble screens. /// - /// The component to capture. This could be the active window or a screen. + /// The component index. /// The X value of the bitmap. /// The Y value of the bitmap. /// The Width value of the bitmap. @@ -669,7 +676,7 @@ public bool SaveScreenshot(int jpegQuality, Screenshot screenshot, ScreenshotCol try { int filepathLengthLimit = Convert.ToInt32(Settings.Application.GetByKey("FilepathLengthLimit", DefaultSettings.FilepathLengthLimit).Value); - + if (!string.IsNullOrEmpty(screenshot.Path)) { if (screenshot.Path.Length > filepathLengthLimit) @@ -709,7 +716,7 @@ public bool SaveScreenshot(int jpegQuality, Screenshot screenshot, ScreenshotCol return false; } - + ApplicationWarning = true; } } diff --git a/app.manifest b/app.manifest index a88c4246..e3d6988e 100644 --- a/app.manifest +++ b/app.manifest @@ -3,7 +3,7 @@ + version="2.3.3.7"/> True/PM diff --git a/interface/FormAbout.resx b/interface/FormAbout.resx index 74d1db7a..10fc755e 100644 --- a/interface/FormAbout.resx +++ b/interface/FormAbout.resx @@ -118,8 +118,8 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - Auto Screen Capture 2.3.3.6 ("Boombayah") -Developed by Gavin Kendall (2008 - 2020) + Auto Screen Capture 2.3.3.7 ("Boombayah") +Developed by Gavin Kendall (2008 - 2021) SourceForge Project Site https://autoscreen.sourceforge.io/ @@ -322,6 +322,7 @@ END OF TERMS AND CONDITIONS Codename "Boombayah" +2.3.3.7 Memory leak fix. 2.3.3.6 Active Window Title text comparison includes type of match to use during text comparison. 2.3.3.5 Application Focus now has Delay Before and Delay After options. 2.3.3.4 A bug fix for saving of file when adding screenshot to collection. diff --git a/settings/Settings.cs b/settings/Settings.cs index bd3cc3a1..2c5d3271 100644 --- a/settings/Settings.cs +++ b/settings/Settings.cs @@ -177,6 +177,7 @@ public static void Initialize() _versionCollection.Add(new Version(CODENAME_BOOMBAYAH, "2.3.3.3")); // An internal list of image hash values are stored when emailing screenshots so we do not email duplicate images. _versionCollection.Add(new Version(CODENAME_BOOMBAYAH, "2.3.3.4")); // A bug fix for saving of file when adding screenshot to collection. _versionCollection.Add(new Version(CODENAME_BOOMBAYAH, "2.3.3.5")); // Application Focus now has Delay Before and Delay After options. + _versionCollection.Add(new Version(CODENAME_BOOMBAYAH, "2.3.3.6")); // Active Window Title text comparison includes type of match to use during text comparison. Application = new SettingCollection {