diff --git a/Greenshot/Forms/MainForm.cs b/Greenshot/Forms/MainForm.cs index 33eca5720..354a7b36a 100644 --- a/Greenshot/Forms/MainForm.cs +++ b/Greenshot/Forms/MainForm.cs @@ -649,9 +649,12 @@ namespace Greenshot { /// Build a selectable list of IE tabs when we enter the menu item /// void CaptureIEMenuDropDownOpening(object sender, EventArgs e) { + if (!conf.IECapture) { + return; + } try { List> tabs = IECaptureHelper.GetTabList(); - this.contextmenu_captureie.DropDownItems.Clear(); + this.contextmenu_captureiefromlist.DropDownItems.Clear(); if (tabs.Count > 0) { this.contextmenu_captureie.Enabled = true; this.contextmenu_captureiefromlist.Enabled = true; @@ -667,7 +670,7 @@ namespace Greenshot { } captureIETabItem.Tag = new KeyValuePair(tabData.Key, index++); captureIETabItem.Click += new System.EventHandler(Contextmenu_captureiefromlist_Click); - this.contextmenu_captureie.DropDownItems.Add(captureIETabItem); + this.contextmenu_captureiefromlist.DropDownItems.Add(captureIETabItem); if (counter.ContainsKey(tabData.Key)) { counter[tabData.Key] = index; } else { diff --git a/Greenshot/Helpers/IECaptureHelper.cs b/Greenshot/Helpers/IECaptureHelper.cs index 297fa40c4..d9713a0a7 100644 --- a/Greenshot/Helpers/IECaptureHelper.cs +++ b/Greenshot/Helpers/IECaptureHelper.cs @@ -82,6 +82,9 @@ namespace Greenshot.Helpers { /// /// public static bool IsIEWindow(WindowDetails someWindow) { + if ("IEFrame".Equals(someWindow.ClassName)) { + return true; + } return someWindow.GetChild("Internet Explorer_Server") != null; } @@ -89,8 +92,7 @@ namespace Greenshot.Helpers { /// Get Windows displaying an IE /// /// List - public static List GetIEWindows() { - List ieWindows = new List(); + public static IEnumerable GetIEWindows() { foreach (WindowDetails possibleIEWindow in WindowDetails.GetAllWindows()) { if (possibleIEWindow.Text.Length == 0) { continue; @@ -99,10 +101,9 @@ namespace Greenshot.Helpers { continue; } if (IsIEWindow(possibleIEWindow)) { - ieWindows.Add(possibleIEWindow); + yield return possibleIEWindow; } } - return ieWindows; } /// @@ -110,7 +111,10 @@ namespace Greenshot.Helpers { /// /// bool public static bool IsIERunning() { - return GetIEWindows().Count > 0; + foreach (WindowDetails ieWindow in GetIEWindows()) { + return true; + } + return false; } /// @@ -122,8 +126,7 @@ namespace Greenshot.Helpers { Dictionary> browserWindows = new Dictionary>(); // Find the IE windows - List ieWindows = GetIEWindows(); - foreach (WindowDetails ieWindow in ieWindows) { + foreach (WindowDetails ieWindow in GetIEWindows()) { try { if (!ieHandleList.Contains(ieWindow.Handle)) { WindowDetails directUIWD = IEHelper.GetDirectUI(ieWindow); diff --git a/Greenshot/Helpers/IEInterop/IEContainer.cs b/Greenshot/Helpers/IEInterop/IEContainer.cs index a4fcd4f04..b8eea34e3 100644 --- a/Greenshot/Helpers/IEInterop/IEContainer.cs +++ b/Greenshot/Helpers/IEInterop/IEContainer.cs @@ -42,8 +42,8 @@ namespace Greenshot.Helpers.IEInterop { private static CoreConfiguration configuration = IniConfig.GetIniSection(); private static readonly List CAPTURE_TAGS = new List(); private const int E_ACCESSDENIED = unchecked((int)0x80070005L); - private static Guid IID_IWebBrowserApp = new Guid("0002DF05-0000-0000-C000-000000000046"); - private static Guid IID_IWebBrowser2 = new Guid("D30C1661-CDAF-11D0-8A3E-00C04FC9E26E"); + private static readonly Guid IID_IWebBrowserApp = new Guid("0002DF05-0000-0000-C000-000000000046"); + private static readonly Guid IID_IWebBrowser2 = new Guid("D30C1661-CDAF-11D0-8A3E-00C04FC9E26E"); private static int counter = 0; private int id = counter++; private IHTMLDocument2 document2; @@ -189,7 +189,6 @@ namespace Greenshot.Helpers.IEInterop { LOG.DebugFormat("Zoomlevel {0}, {1}", zoomLevelX, zoomLevelY); } catch (Exception e) { LOG.Warn("Can't get certain properties for documents, using default. due to: ", e); - } @@ -200,6 +199,7 @@ namespace Greenshot.Helpers.IEInterop { } } catch { } + try { url = document2.url; } catch { @@ -311,7 +311,9 @@ namespace Greenshot.Helpers.IEInterop { // Use IServiceProvider.QueryService to get IWebBrowser2 object. Object brws = null; - sp.QueryService(ref IID_IWebBrowserApp, ref IID_IWebBrowser2, out brws); + Guid webBrowserApp = IID_IWebBrowserApp.Clone(); + Guid webBrowser2 = IID_IWebBrowser2.Clone(); + sp.QueryService(ref webBrowserApp, ref webBrowser2, out brws); // Get the document from IWebBrowser2. IWebBrowser2 browser = (IWebBrowser2)(brws); diff --git a/GreenshotPlugin/Core/PluginUtils.cs b/GreenshotPlugin/Core/PluginUtils.cs index 4898f5ece..a1cf4c906 100644 --- a/GreenshotPlugin/Core/PluginUtils.cs +++ b/GreenshotPlugin/Core/PluginUtils.cs @@ -105,8 +105,11 @@ namespace GreenshotPlugin.Core { // Check if we need to add a new separator, which is done if the first found has a Tag with the value "PluginsAreAddedBefore" if ("PluginsAreAddedBefore".Equals(contextMenu.Items[i].Tag)) { ToolStripSeparator separator = new ToolStripSeparator(); + separator.Tag = "PluginsAreAddedAfter"; separator.Size = new Size(305, 6); contextMenu.Items.Insert(i, separator); + } else if (!"PluginsAreAddedAfter".Equals(contextMenu.Items[i].Tag)) { + continue; } contextMenu.Items.Insert(i + 1, item); addedItem = true;