two fixes to avoid exceptions when trying to capture IE content from IE instances embedded in other applications

git-svn-id: http://svn.code.sf.net/p/greenshot/code/trunk@2043 7dccd23d-a4a3-4e1f-8c07-b4c1b4018ab4
This commit is contained in:
JKlingen 2012-09-14 20:55:42 +00:00
parent 8edfc71c9c
commit b6a686db28

View file

@ -48,6 +48,7 @@ namespace Greenshot.Helpers {
// Helper method to activate a certain IE Tab
public static void ActivateIETab(WindowDetails ieWindowDetails, int tabIndex) {
WindowDetails directUIWindowDetails = IEHelper.GetDirectUI(ieWindowDetails);
if(directUIWindowDetails != null) {
// Bring window to the front
ieWindowDetails.Restore();
// Get accessible
@ -55,6 +56,7 @@ namespace Greenshot.Helpers {
// Activate Tab
ieAccessible.ActivateIETab(tabIndex);
}
}
/// <summary>
/// Return true if the supplied window has a sub-window which covers more than the supplied percentage
@ -411,6 +413,7 @@ namespace Greenshot.Helpers {
// Store the URL of the page
if (documentContainer.Url != null) {
try {
Uri uri = new Uri(documentContainer.Url);
capture.CaptureDetails.AddMetaData("URL", uri.OriginalString);
// As the URL can hardly be used in a filename, the following can be used
@ -430,6 +433,9 @@ namespace Greenshot.Helpers {
capture.CaptureDetails.AddMetaData("URL_USER", uri.UserInfo);
}
capture.CaptureDetails.AddMetaData("URL_PORT", uri.Port.ToString());
} catch(Exception e) {
LOG.Warn("Exception when trying to use url in metadata "+documentContainer.Url,e);
}
}
// Only move the mouse to correct for the capture offset