diff --git a/Greenshot/Forms/CaptureForm.cs b/Greenshot/Forms/CaptureForm.cs index 86ea4054f..7af509c03 100644 --- a/Greenshot/Forms/CaptureForm.cs +++ b/Greenshot/Forms/CaptureForm.cs @@ -300,6 +300,10 @@ namespace Greenshot.Forms { HandleMouseUp(); } break; + case Keys.F: + ToFront = !ToFront; + TopMost = !TopMost; + break; } } #endregion diff --git a/GreenshotOfficePlugin/OfficeExport/ExcelExporter.cs b/GreenshotOfficePlugin/OfficeExport/ExcelExporter.cs index 74fc732a0..f65a3e33e 100644 --- a/GreenshotOfficePlugin/OfficeExport/ExcelExporter.cs +++ b/GreenshotOfficePlugin/OfficeExport/ExcelExporter.cs @@ -22,6 +22,7 @@ using System; using System.Collections.Generic; using System.Reflection; using System.Drawing; +using GreenshotPlugin.Core; namespace Greenshot.Interop.Office { public class ExcelExporter { @@ -72,6 +73,11 @@ namespace Greenshot.Interop.Office { } } } + int hWnd = excelApplication.Hwnd; + if (hWnd > 0) + { + WindowDetails.ToForeground(new IntPtr(hWnd)); + } } } diff --git a/GreenshotOfficePlugin/OfficeExport/WordExporter.cs b/GreenshotOfficePlugin/OfficeExport/WordExporter.cs index 548914287..350f51fd8 100644 --- a/GreenshotOfficePlugin/OfficeExport/WordExporter.cs +++ b/GreenshotOfficePlugin/OfficeExport/WordExporter.cs @@ -22,6 +22,7 @@ using System; using System.Collections.Generic; using GreenshotOfficePlugin; using Greenshot.IniFile; +using GreenshotPlugin.Core; namespace Greenshot.Interop.Office { public class WordExporter { @@ -123,7 +124,15 @@ namespace Greenshot.Interop.Office { // ignored } try { - wordDocument.Activate(); + using (var activeWindow = wordDocument.ActiveWindow) + { + activeWindow.Activate(); + int hWnd = activeWindow.Hwnd; + if (hWnd > 0) + { + WindowDetails.ToForeground(new IntPtr(hWnd)); + } + } } catch { @@ -192,7 +201,15 @@ namespace Greenshot.Interop.Office { // ignored } try { - wordDocument.ActiveWindow.Activate(); + using (var activeWindow = wordDocument.ActiveWindow) + { + activeWindow.Activate(); + int hWnd = activeWindow.Hwnd; + if (hWnd > 0) + { + WindowDetails.ToForeground(new IntPtr(hWnd)); + } + } } catch { diff --git a/GreenshotOfficePlugin/OfficeInterop/ExcelInterop.cs b/GreenshotOfficePlugin/OfficeInterop/ExcelInterop.cs index 9e6292fae..4ff22b066 100644 --- a/GreenshotOfficePlugin/OfficeInterop/ExcelInterop.cs +++ b/GreenshotOfficePlugin/OfficeInterop/ExcelInterop.cs @@ -37,13 +37,21 @@ namespace Greenshot.Interop.Office { string Version { get; } + + /// + /// Returns an Integer indicating the top-level window handle of the Microsoft Excel window. + /// + int Hwnd + { + get; + } } // See: http://msdn.microsoft.com/en-us/library/microsoft.office.interop.excel.workbooks.aspx public interface IWorkbooks : ICommon, ICollection { IWorkbook Add(object template); // Use index + 1!! - IWorkbook this[object Index] { + IWorkbook this[object index] { get; } } @@ -76,14 +84,14 @@ namespace Greenshot.Interop.Office { } // See: http://msdn.microsoft.com/en-us/library/microsoft.office.interop.excel.iworksheets_members.aspx - public interface IWorksheets : ICommon, ICollection { + public interface IWorksheets : ICollection { // Use index + 1!! - IWorksheet this[object Index] { + IWorksheet this[object index] { get; } } - public interface IPictures : ICommon, ICollection { + public interface IPictures : ICollection { // Use index + 1!! //IPicture this[object Index] { get; } void Insert(string file); diff --git a/GreenshotOfficePlugin/OfficeInterop/OutlookInterop.cs b/GreenshotOfficePlugin/OfficeInterop/OutlookInterop.cs index f91390271..2fee5863d 100644 --- a/GreenshotOfficePlugin/OfficeInterop/OutlookInterop.cs +++ b/GreenshotOfficePlugin/OfficeInterop/OutlookInterop.cs @@ -289,7 +289,9 @@ namespace Greenshot.Interop.Office { } } - // See: http://msdn.microsoft.com/en-us/library/microsoft.office.interop.outlook.inspector_members.aspx + /// + /// See: http://msdn.microsoft.com/en-us/library/microsoft.office.interop.outlook.inspector_members.aspx + /// public interface IInspector : ICommonExplorer { IItem CurrentItem { get; diff --git a/GreenshotOfficePlugin/OfficeInterop/WordInterop.cs b/GreenshotOfficePlugin/OfficeInterop/WordInterop.cs index 2c2162cbf..2a2f63420 100644 --- a/GreenshotOfficePlugin/OfficeInterop/WordInterop.cs +++ b/GreenshotOfficePlugin/OfficeInterop/WordInterop.cs @@ -60,6 +60,11 @@ namespace Greenshot.Interop.Office { string Caption { get; } + + /// + /// Returns an Integer (int in C#) that indicates the window handle of the specified window + /// + int Hwnd { get; } } /// diff --git a/GreenshotPlugin/Core/AbstractDestination.cs b/GreenshotPlugin/Core/AbstractDestination.cs index 1980e2614..8b7ea5c19 100644 --- a/GreenshotPlugin/Core/AbstractDestination.cs +++ b/GreenshotPlugin/Core/AbstractDestination.cs @@ -152,7 +152,8 @@ namespace GreenshotPlugin.Core { var menu = new ContextMenuStrip { ImageScalingSize = CoreConfig.IconSize, - Tag = null + Tag = null, + TopLevel = true }; menu.Closing += delegate(object source, ToolStripDropDownClosingEventArgs eventArgs) { diff --git a/GreenshotPlugin/Core/WindowsHelper.cs b/GreenshotPlugin/Core/WindowsHelper.cs index bc4aad664..1a6db39a1 100644 --- a/GreenshotPlugin/Core/WindowsHelper.cs +++ b/GreenshotPlugin/Core/WindowsHelper.cs @@ -1256,7 +1256,6 @@ namespace GreenshotPlugin.Core { /// public static void ToForeground(IntPtr handle) { - // Do nothing if the window is already in the foreground if (User32.GetForegroundWindow() == handle) {