Some more IE Capture stability fixes, they are most likely not working.

git-svn-id: http://svn.code.sf.net/p/greenshot/code/trunk@2031 7dccd23d-a4a3-4e1f-8c07-b4c1b4018ab4
This commit is contained in:
RKrom 2012-09-14 14:21:37 +00:00
commit 613960eb0a
2 changed files with 38 additions and 25 deletions

View file

@ -231,7 +231,9 @@ namespace Greenshot.Helpers {
ieAccessible = new Accessible(directUIWD.Handle); ieAccessible = new Accessible(directUIWD.Handle);
} }
if (ieAccessible == null) { if (ieAccessible == null) {
if (browserWindow != null) {
LOG.InfoFormat("Active Window is {0}", browserWindow.Text); LOG.InfoFormat("Active Window is {0}", browserWindow.Text);
}
if (!ieWindow.Equals(browserWindow)) { if (!ieWindow.Equals(browserWindow)) {
LOG.WarnFormat("No ieAccessible for {0}", ieWindow.Text); LOG.WarnFormat("No ieAccessible for {0}", ieWindow.Text);
continue; continue;

View file

@ -153,8 +153,8 @@ namespace Greenshot.Helpers.IEInterop {
} }
Rectangle clientRectangle = contentWindow.WindowRectangle; Rectangle clientRectangle = contentWindow.WindowRectangle;
try { try {
IHTMLWindow3 window3 = (IHTMLWindow3)document2.parentWindow;
IHTMLWindow2 window2 = (IHTMLWindow2)document2.parentWindow; IHTMLWindow2 window2 = (IHTMLWindow2)document2.parentWindow;
//IHTMLWindow3 window3 = (IHTMLWindow3)document2.parentWindow;
IHTMLScreen2 screen2 = (IHTMLScreen2)window2.screen; IHTMLScreen2 screen2 = (IHTMLScreen2)window2.screen;
IHTMLScreen screen = window2.screen; IHTMLScreen screen = window2.screen;
if (parent != null) { if (parent != null) {
@ -172,7 +172,7 @@ namespace Greenshot.Helpers.IEInterop {
// Calculate the viewport rectangle, needed if there is a frame around the html window // Calculate the viewport rectangle, needed if there is a frame around the html window
LOG.DebugFormat("Screen {0}x{1}", ScaleX(screen.width), ScaleY(screen.height)); LOG.DebugFormat("Screen {0}x{1}", ScaleX(screen.width), ScaleY(screen.height));
LOG.DebugFormat("Screen location {0},{1}", window3.screenLeft, window3.screenTop); //LOG.DebugFormat("Screen location {0},{1}", window3.screenLeft, window3.screenTop);
LOG.DebugFormat("Window rectangle {0}", clientRectangle); LOG.DebugFormat("Window rectangle {0}", clientRectangle);
LOG.DebugFormat("Client size {0}x{1}", ClientWidth, ClientHeight); LOG.DebugFormat("Client size {0}x{1}", ClientWidth, ClientHeight);
int diffX = clientRectangle.Width - ClientWidth; int diffX = clientRectangle.Width - ClientWidth;
@ -188,7 +188,7 @@ namespace Greenshot.Helpers.IEInterop {
} }
LOG.DebugFormat("Zoomlevel {0}, {1}", zoomLevelX, zoomLevelY); LOG.DebugFormat("Zoomlevel {0}, {1}", zoomLevelX, zoomLevelY);
} catch (Exception e) { } catch (Exception e) {
LOG.Warn("Can't get certain properties for documents, using default. due to: ", e); LOG.Warn("Can't get certain properties for documents, using default. Due to: ", e);
} }
@ -197,12 +197,14 @@ namespace Greenshot.Helpers.IEInterop {
if (name == null) { if (name == null) {
name = document2.title; name = document2.title;
} }
} catch { } catch (Exception e) {
LOG.Warn("Problem while trying to get document title!", e);
} }
try { try {
url = document2.url; url = document2.url;
} catch { } catch (Exception e) {
LOG.Warn("Problem while trying to get document url!", e);
} }
sourceLocation = new Point(ScaleX((int)startLocation.X), ScaleY((int)startLocation.Y)); sourceLocation = new Point(ScaleX((int)startLocation.X), ScaleY((int)startLocation.Y));
destinationLocation = new Point(ScaleX((int)startLocation.X), ScaleY((int)startLocation.Y)); destinationLocation = new Point(ScaleX((int)startLocation.X), ScaleY((int)startLocation.Y));
@ -210,6 +212,7 @@ namespace Greenshot.Helpers.IEInterop {
if (parent != null) { if (parent != null) {
return; return;
} }
try {
IHTMLFramesCollection2 frameCollection = (IHTMLFramesCollection2)document2.frames; IHTMLFramesCollection2 frameCollection = (IHTMLFramesCollection2)document2.frames;
for (int frame = 0; frame < frameCollection.length; frame++) { for (int frame = 0; frame < frameCollection.length; frame++) {
try { try {
@ -226,6 +229,11 @@ namespace Greenshot.Helpers.IEInterop {
LOG.Warn("Problem while trying to get information from a frame, skipping the frame!", e); LOG.Warn("Problem while trying to get information from a frame, skipping the frame!", e);
} }
} }
} catch (Exception ex) {
LOG.Warn("Problem while trying to get the frames, skipping!", ex);
}
try {
// Correct iframe locations // Correct iframe locations
foreach (IHTMLElement frameElement in document3.getElementsByTagName("IFRAME")) { foreach (IHTMLElement frameElement in document3.getElementsByTagName("IFRAME")) {
try { try {
@ -234,6 +242,9 @@ namespace Greenshot.Helpers.IEInterop {
LOG.Warn("Problem while trying to get information from an iframe, skipping the frame!", e); LOG.Warn("Problem while trying to get information from an iframe, skipping the frame!", e);
} }
} }
} catch (Exception ex) {
LOG.Warn("Problem while trying to get the iframes, skipping!", ex);
}
} }
private void DisableScrollbars(IHTMLDocument2 document2) { private void DisableScrollbars(IHTMLDocument2 document2) {