From 94c0f1064f7e1163b8d717547d86ac2040544199 Mon Sep 17 00:00:00 2001 From: RKrom Date: Wed, 13 Mar 2013 16:56:57 +0000 Subject: [PATCH] Making capture more stable for #1475 git-svn-id: http://svn.code.sf.net/p/greenshot/code/trunk@2532 7dccd23d-a4a3-4e1f-8c07-b4c1b4018ab4 --- Greenshot/Helpers/IECaptureHelper.cs | 43 +++++++++++++++++----------- 1 file changed, 27 insertions(+), 16 deletions(-) diff --git a/Greenshot/Helpers/IECaptureHelper.cs b/Greenshot/Helpers/IECaptureHelper.cs index 3173c6cc2..da04b45c1 100644 --- a/Greenshot/Helpers/IECaptureHelper.cs +++ b/Greenshot/Helpers/IECaptureHelper.cs @@ -357,12 +357,14 @@ namespace Greenshot.Helpers { LOG.Debug("Nothing to capture found"); return null; } - LOG.DebugFormat("Window class {0}", documentContainer.ContentWindow.ClassName); - LOG.DebugFormat("Window location {0}", documentContainer.ContentWindow.Location); - // The URL is available unter "document2.url" and can be used to enhance the meta-data etc. - capture.CaptureDetails.AddMetaData("url", documentContainer.Url); - + try { + LOG.DebugFormat("Window class {0}", documentContainer.ContentWindow.ClassName); + LOG.DebugFormat("Window location {0}", documentContainer.ContentWindow.Location); + } catch (Exception ex) { + LOG.Warn("Error while logging information.", ex); + } + // bitmap to return Bitmap returnBitmap = null; Size pageSize = Size.Empty; @@ -405,14 +407,20 @@ namespace Greenshot.Helpers { // Store the bitmap for further processing capture.Image = returnBitmap; - // Store the location of the window - capture.Location = documentContainer.ContentWindow.Location; + try { + // Store the location of the window + capture.Location = documentContainer.ContentWindow.Location; - // Store the title of the page - if (documentContainer.Name != null) { - capture.CaptureDetails.Title = documentContainer.Name; - } else { - capture.CaptureDetails.Title = windowToCapture.Text; + // The URL is available unter "document2.url" and can be used to enhance the meta-data etc. + capture.CaptureDetails.AddMetaData("url", documentContainer.Url); + // Store the title of the page + if (documentContainer.Name != null) { + capture.CaptureDetails.Title = documentContainer.Name; + } else { + capture.CaptureDetails.Title = windowToCapture.Text; + } + } catch (Exception ex) { + LOG.Warn("Problems getting some attributes...", ex); } // Store the URL of the page @@ -441,10 +449,13 @@ namespace Greenshot.Helpers { LOG.Warn("Exception when trying to use url in metadata "+documentContainer.Url,e); } } - - // Only move the mouse to correct for the capture offset - capture.MoveMouseLocation(-documentContainer.ViewportRectangle.X, -documentContainer.ViewportRectangle.Y); - // Used to be: capture.MoveMouseLocation(-(capture.Location.X + documentContainer.CaptureOffset.X), -(capture.Location.Y + documentContainer.CaptureOffset.Y)); + try { + // Only move the mouse to correct for the capture offset + capture.MoveMouseLocation(-documentContainer.ViewportRectangle.X, -documentContainer.ViewportRectangle.Y); + // Used to be: capture.MoveMouseLocation(-(capture.Location.X + documentContainer.CaptureOffset.X), -(capture.Location.Y + documentContainer.CaptureOffset.Y)); + } catch (Exception ex) { + LOG.Warn("Error while correcting the mouse offset.", ex); + } } finally { // Always close the background form backgroundForm.CloseDialog();