Skip to content

Commit 70fd25f

Browse files
committed
2.3.4.4 - Fix to Screen Capture method.
1 parent b0b1cd2 commit 70fd25f

File tree

6 files changed

+37
-36
lines changed

6 files changed

+37
-36
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.3")]
36-
[assembly: AssemblyFileVersion("2.3.4.3")]
35+
[assembly: AssemblyVersion("2.3.4.4")]
36+
[assembly: AssemblyFileVersion("2.3.4.4")]
3737
[assembly: NeutralResourcesLanguageAttribute("en-CA")]

ScreenCapture.cs

Lines changed: 30 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -449,55 +449,55 @@ public Image GetImageByPath(string path)
449449
/// <returns>A bitmap image representing what we captured.</returns>
450450
public Bitmap GetScreenBitmap(int source, int component, int x, int y, int width, int height, bool mouse)
451451
{
452-
try
452+
if (width > 0 && height > 0)
453453
{
454-
if (width > 0 && height > 0)
454+
if (source > 0 && component > -1)
455455
{
456-
if (source > 0 && component > -1)
456+
try
457457
{
458458
// Test if we can acquire the actual screen from Windows and if we can't just let this
459459
// method catch the out of bounds exception error.
460460
System.Windows.Forms.Screen screen = System.Windows.Forms.Screen.AllScreens[component];
461461
}
462+
catch
463+
{
464+
return null;
465+
}
466+
}
462467

463-
Size blockRegionSize = new Size(width, height);
468+
Size blockRegionSize = new Size(width, height);
464469

465-
Bitmap bmp = new Bitmap(width, height);
470+
Bitmap bmp = new Bitmap(width, height);
466471

467-
using (Graphics g = Graphics.FromImage(bmp))
472+
using (Graphics g = Graphics.FromImage(bmp))
473+
{
474+
g.CopyFromScreen(x, y, 0, 0, blockRegionSize, CopyPixelOperation.SourceCopy);
475+
476+
if (mouse)
468477
{
469-
g.CopyFromScreen(x, y, 0, 0, blockRegionSize, CopyPixelOperation.SourceCopy);
478+
CURSORINFO pci;
479+
pci.cbSize = Marshal.SizeOf(typeof(CURSORINFO));
470480

471-
if (mouse)
481+
if (GetCursorInfo(out pci))
472482
{
473-
CURSORINFO pci;
474-
pci.cbSize = Marshal.SizeOf(typeof(CURSORINFO));
475-
476-
if (GetCursorInfo(out pci))
483+
if (pci.flags == CURSOR_SHOWING)
477484
{
478-
if (pci.flags == CURSOR_SHOWING)
479-
{
480-
var hdc = g.GetHdc();
481-
DrawIconEx(hdc, pci.ptScreenPos.x - x, pci.ptScreenPos.y - y, pci.hCursor, 0, 0, 0, IntPtr.Zero, DI_NORMAL);
482-
g.ReleaseHdc();
483-
}
485+
var hdc = g.GetHdc();
486+
DrawIconEx(hdc, pci.ptScreenPos.x - x, pci.ptScreenPos.y - y, pci.hCursor, 0, 0, 0, IntPtr.Zero, DI_NORMAL);
487+
g.ReleaseHdc();
484488
}
485489
}
486490
}
487-
488-
CaptureError = false;
489-
490-
return bmp;
491491
}
492492

493-
CaptureError = true;
493+
CaptureError = false;
494494

495-
return null;
496-
}
497-
catch
498-
{
499-
return null;
495+
return bmp;
500496
}
497+
498+
CaptureError = true;
499+
500+
return null;
501501
}
502502

503503
/// <summary>
@@ -619,19 +619,17 @@ public bool GetScreenImages(int source, int component, int x, int y, int width,
619619
{
620620
try
621621
{
622+
CaptureError = false;
623+
622624
bitmap = source == 0 && component == 0
623625
? GetActiveWindowBitmap()
624626
: GetScreenBitmap(source, component, x, y, width, height, mouse);
625627

626628
if (bitmap != null)
627629
{
628-
CaptureError = false;
629-
630630
return true;
631631
}
632632

633-
CaptureError = true;
634-
635633
return false;
636634
}
637635
catch (Exception ex)

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.3"/>
6+
version="2.3.4.4"/>
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.4 Fix to Screen Capture method.
78
2.3.4.3 Fix to Screen Capture method.
89
2.3.4.2 Fix to Screen form for preview image.
910
2.3.4.1 Does not capture image of screen if screen does not exist.

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.3 ("Boombayah")
121+
<value>Auto Screen Capture 2.3.4.34 ("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.4 Fix to Screen Capture method.
143144
2.3.4.3 Fix to Screen Capture method.
144145
2.3.4.2 Fix to Screen form for preview image.
145146
2.3.4.1 Does not capture image of screen if screen does not exist.

settings/Settings.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,7 @@ public void Load(FileSystem fileSystem)
222222
_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.
223223
_versionCollection.Add(new Version(CODENAME_BOOMBAYAH, "2.3.4.1")); // Does not capture image of screen if screen does not exist.
224224
_versionCollection.Add(new Version(CODENAME_BOOMBAYAH, "2.3.4.2")); // Fix to Screen form for preview image.
225+
_versionCollection.Add(new Version(CODENAME_BOOMBAYAH, "2.3.4.3")); // Fix to Screen form for preview image.
225226

226227
Application = new SettingCollection()
227228
{

0 commit comments

Comments
 (0)