diff --git a/Greenshot/Helpers/CaptureHelper.cs b/Greenshot/Helpers/CaptureHelper.cs index 2958a9f43..a3c12e21a 100644 --- a/Greenshot/Helpers/CaptureHelper.cs +++ b/Greenshot/Helpers/CaptureHelper.cs @@ -412,7 +412,9 @@ namespace Greenshot.Helpers { Thread getWindowDetailsThread = new Thread (delegate() { // Start Enumeration of "active" windows - foreach (WindowDetails window in WindowDetails.GetAllWindows()) { + List allWindows = WindowDetails.GetMetroApps(); + allWindows.AddRange(WindowDetails.GetAllWindows()); + foreach (WindowDetails window in allWindows) { // Window should be visible and not ourselves if (!window.Visible) { continue; @@ -456,9 +458,9 @@ namespace Greenshot.Helpers { // AddCaptureElementsForWindow(windowCaptureElement, window, goLevelDeep); //} } - lock (windows) { - windows = WindowDetails.SortByZOrder(IntPtr.Zero, windows); - } +// lock (windows) { +// windows = WindowDetails.SortByZOrder(IntPtr.Zero, windows); +// } }); getWindowDetailsThread.Name = "Retrieve window details"; getWindowDetailsThread.IsBackground = true; diff --git a/GreenshotPlugin/Core/WindowsHelper.cs b/GreenshotPlugin/Core/WindowsHelper.cs index bacf49bd9..6e66afe2e 100644 --- a/GreenshotPlugin/Core/WindowsHelper.cs +++ b/GreenshotPlugin/Core/WindowsHelper.cs @@ -181,6 +181,11 @@ namespace GreenshotPlugin.Core { private WindowDetails parent = null; private bool frozen = false; + public bool isMetroApp { + get; + set; + } + /// /// The window handle. /// @@ -246,6 +251,10 @@ namespace GreenshotPlugin.Core { /// public Image DisplayIcon { get { + if (isMetroApp) { + // No method yet to get the metro icon + return null; + } try { string filename = ProcessPath; if (!iconCache.ContainsKey(filename)) { @@ -1320,7 +1329,8 @@ namespace GreenshotPlugin.Core { public static List GetVisibleWindows() { List windows = new List(); Rectangle screenBounds = WindowCapture.GetScreenBounds(); - List allWindows = WindowDetails.GetAllWindows(); + List allWindows = GetMetroApps(); + allWindows.AddRange(WindowDetails.GetAllWindows()); foreach(WindowDetails window in allWindows) { // Ignore windows without title if (window.Text.Length == 0) { @@ -1346,15 +1356,34 @@ namespace GreenshotPlugin.Core { return windows; } + /// + /// Get the WindowDetails for all Metro Apps + /// These are all Windows with Classname "Windows.UI.Core.CoreWindow" + /// + /// List with visible metro apps + public static List GetMetroApps() { + List metroApps = new List(); + IntPtr nextHandle = User32.FindWindow("Windows.UI.Core.CoreWindow", null); + while (nextHandle != IntPtr.Zero) { + WindowDetails metroApp = new WindowDetails(nextHandle); + metroApp.isMetroApp = true; + metroApps.Add(metroApp); + LOG.DebugFormat("Found metro app {0}", metroApp.Text); + nextHandle = User32.FindWindowEx( IntPtr.Zero, nextHandle, "Windows.UI.Core.CoreWindow", null); + }; + + return metroApps; + } + /// /// Get all the top level windows /// /// List with all the top level windows public static List GetTopLevelWindows() { List windows = new List(); - Rectangle screenBounds = WindowCapture.GetScreenBounds(); - List allWindows = WindowDetails.GetAllWindows(); - foreach (WindowDetails window in allWindows) { + var possibleTopLevelWindows = GetMetroApps(); + possibleTopLevelWindows.AddRange(WindowDetails.GetAllWindows()); + foreach (WindowDetails window in possibleTopLevelWindows) { // Ignore windows without title if (window.Text.Length == 0) { continue;