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) {
LOG.InfoFormat("Active Window is {0}", browserWindow.Text); if (browserWindow != null) {
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,29 +212,38 @@ namespace Greenshot.Helpers.IEInterop {
if (parent != null) { if (parent != null) {
return; return;
} }
IHTMLFramesCollection2 frameCollection = (IHTMLFramesCollection2)document2.frames; try {
for(int frame = 0; frame < frameCollection.length; frame++) { IHTMLFramesCollection2 frameCollection = (IHTMLFramesCollection2)document2.frames;
try { for (int frame = 0; frame < frameCollection.length; frame++) {
IHTMLWindow2 frameWindow = frameCollection.item(frame); try {
DocumentContainer frameData = new DocumentContainer(frameWindow, contentWindow, this); IHTMLWindow2 frameWindow = frameCollection.item(frame);
// check if frame is hidden DocumentContainer frameData = new DocumentContainer(frameWindow, contentWindow, this);
if (!frameData.isHidden) { // check if frame is hidden
LOG.DebugFormat("Creating DocumentContainer for Frame {0} found in window with rectangle {1}", frameData.name, frameData.SourceRectangle); if (!frameData.isHidden) {
frames.Add(frameData); LOG.DebugFormat("Creating DocumentContainer for Frame {0} found in window with rectangle {1}", frameData.name, frameData.SourceRectangle);
} else { frames.Add(frameData);
LOG.DebugFormat("Skipping frame {0}", frameData.Name); } else {
LOG.DebugFormat("Skipping frame {0}", frameData.Name);
}
} catch (Exception e) {
LOG.Warn("Problem while trying to get information from a frame, skipping the frame!", e);
} }
} catch (Exception 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);
} }
// Correct iframe locations
foreach (IHTMLElement frameElement in document3.getElementsByTagName("IFRAME")){ try {
try { // Correct iframe locations
CorrectFrameLocations(frameElement); foreach (IHTMLElement frameElement in document3.getElementsByTagName("IFRAME")) {
} catch (Exception e) { try {
LOG.Warn("Problem while trying to get information from an iframe, skipping the frame!", e); CorrectFrameLocations(frameElement);
} catch (Exception 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);
} }
} }