Skip to content

Commit b8ca44d

Browse files
committed
2.3.4.1 - Does not capture image of screen if screen does not exist.
1 parent 90bae94 commit b8ca44d

File tree

7 files changed

+28
-19
lines changed

7 files changed

+28
-19
lines changed

Properties/AssemblyInfo.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,6 @@
3232
// You can specify all the values or you can default the Build and Revision Numbers
3333
// by using the '*' as shown below:
3434
// [assembly: AssemblyVersion("1.0.*")]
35-
[assembly: AssemblyVersion("2.3.4.0")]
36-
[assembly: AssemblyFileVersion("2.3.4.0")]
35+
[assembly: AssemblyVersion("2.3.4.1")]
36+
[assembly: AssemblyFileVersion("2.3.4.1")]
3737
[assembly: NeutralResourcesLanguageAttribute("en-CA")]

ScreenCapture.cs

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -439,18 +439,27 @@ public Image GetImageByPath(string path)
439439
/// <summary>
440440
/// Gets the bitmap image of the screen based on X, Y, Width, and Height. This is used by Screens and Regions.
441441
/// </summary>
442+
/// <param name="source">The source.</param>
443+
/// <param name="component">The component of the source.</param>
442444
/// <param name="x">The X value of the bitmap.</param>
443445
/// <param name="y">The Y value of the bitmap.</param>
444446
/// <param name="width">The Width value of the bitmap.</param>
445447
/// <param name="height">The Height value of the bitmap.</param>
446448
/// <param name="mouse">Determines if the mouse pointer should be included in the bitmap.</param>
447449
/// <returns>A bitmap image representing what we captured.</returns>
448-
public Bitmap GetScreenBitmap(int x, int y, int width, int height, bool mouse)
450+
public Bitmap GetScreenBitmap(int source, int component, int x, int y, int width, int height, bool mouse)
449451
{
450452
try
451453
{
452454
if (width > 0 && height > 0)
453455
{
456+
if (source > 0 && component > -1)
457+
{
458+
// Test if we can acquire the actual screen from Windows and if we can't just let this
459+
// method catch the out of bounds exception error.
460+
System.Windows.Forms.Screen screen = System.Windows.Forms.Screen.AllScreens[component];
461+
}
462+
454463
Size blockRegionSize = new Size(width, height);
455464

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

486495
return null;
487496
}
488-
catch (Exception ex)
497+
catch
489498
{
490-
// Don't log an error if Windows is locked at the time a screenshot was taken.
491-
if (!ex.Message.Equals("The handle is invalid"))
492-
{
493-
_log.WriteExceptionMessage("ScreenCapture::GetScreenBitmap", ex);
494-
}
495-
496499
CaptureError = true;
497500

498501
return null;
@@ -620,7 +623,7 @@ public bool GetScreenImages(int source, int component, int x, int y, int width,
620623
{
621624
bitmap = source == 0 && component == 0
622625
? GetActiveWindowBitmap()
623-
: GetScreenBitmap(x, y, width, height, mouse);
626+
: GetScreenBitmap(source, component, x, y, width, height, mouse);
624627

625628
if (bitmap != null)
626629
{

app.manifest

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<assemblyIdentity
44
type="win32"
55
name="GavinKendall.AutoScreenCapture"
6-
version="2.3.4.0"/>
6+
version="2.3.4.1"/>
77
<asmv3:application>
88
<asmv3:windowsSettings xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">
99
<dpiAware>True/PM</dpiAware>

changelog.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ Auto Screen Capture by Gavin Kendall
44

55

66
Codename "Boombayah"
7+
2.3.4.1 Does not capture image of screen if screen does not exist.
78
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.
89
2.3.3.9 Dashboard introduced so you can have an overview of all screens and regions.
910
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.

interface/FormAbout.resx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@
118118
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
119119
</resheader>
120120
<data name="richTextBoxApplication.Text" xml:space="preserve">
121-
<value>Auto Screen Capture 2.3.4.0 ("Boombayah")
121+
<value>Auto Screen Capture 2.3.4.1 ("Boombayah")
122122
Developed by Gavin Kendall (2008 - 2021)
123123

124124
SourceForge Project Site
@@ -140,6 +140,7 @@ Triggers have been rewritten. I haven't spent much time on the new wizard-style
140140
</data>
141141
<data name="richTextBoxChangelog.Text" xml:space="preserve">
142142
<value>Codename "Boombayah"
143+
2.3.4.1 Does not capture image of screen if screen does not exist.
143144
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.
144145
2.3.3.9 Dashboard introduced so you can have an overview of all screens and regions.
145146
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.

modules/regions/FormRegion.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -330,6 +330,8 @@ private void UpdatePreviewImage(ScreenCapture screenCapture)
330330
if (checkBoxActive.Checked)
331331
{
332332
pictureBoxPreview.Image = screenCapture.GetScreenBitmap(
333+
-1,
334+
-1,
333335
(int)numericUpDownX.Value,
334336
(int)numericUpDownY.Value,
335337
(int)numericUpDownWidth.Value,

modules/screens/FormScreen.cs

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -376,12 +376,14 @@ private void UpdatePreviewImage(ScreenCapture screenCapture)
376376
else
377377
{
378378
pictureBoxPreview.Image = screenCapture.GetScreenBitmap(
379-
(int)numericUpDownX.Value,
380-
(int)numericUpDownY.Value,
381-
(int)numericUpDownWidth.Value,
382-
(int)numericUpDownHeight.Value,
383-
checkBoxMouse.Checked
384-
);
379+
comboBoxScreenSource.SelectedIndex,
380+
comboBoxScreenComponent.SelectedIndex,
381+
(int)numericUpDownX.Value,
382+
(int)numericUpDownY.Value,
383+
(int)numericUpDownWidth.Value,
384+
(int)numericUpDownHeight.Value,
385+
checkBoxMouse.Checked
386+
);
385387
}
386388

387389
UpdatePreviewMacro();

0 commit comments

Comments
 (0)