Added some very basic support for Metro (Modern UI) Apps, the ones running can be captured over the "Capture window from list" and the one visible will be selectable with the interactive capture. (PrintScreen and space). What doesn't work is using printscreen on the Metro Tiles screen, here the space will only work like the desktop is visible.

git-svn-id: http://svn.code.sf.net/p/greenshot/code/trunk@2247 7dccd23d-a4a3-4e1f-8c07-b4c1b4018ab4
This commit is contained in:
RKrom 2012-11-08 07:00:29 +00:00
parent d545bc8ec3
commit ae8c007528
2 changed files with 39 additions and 8 deletions

View file

@ -412,7 +412,9 @@ namespace Greenshot.Helpers {
Thread getWindowDetailsThread = new Thread (delegate() { Thread getWindowDetailsThread = new Thread (delegate() {
// Start Enumeration of "active" windows // Start Enumeration of "active" windows
foreach (WindowDetails window in WindowDetails.GetAllWindows()) { List<WindowDetails> allWindows = WindowDetails.GetMetroApps();
allWindows.AddRange(WindowDetails.GetAllWindows());
foreach (WindowDetails window in allWindows) {
// Window should be visible and not ourselves // Window should be visible and not ourselves
if (!window.Visible) { if (!window.Visible) {
continue; continue;
@ -456,9 +458,9 @@ namespace Greenshot.Helpers {
// AddCaptureElementsForWindow(windowCaptureElement, window, goLevelDeep); // AddCaptureElementsForWindow(windowCaptureElement, window, goLevelDeep);
//} //}
} }
lock (windows) { // lock (windows) {
windows = WindowDetails.SortByZOrder(IntPtr.Zero, windows); // windows = WindowDetails.SortByZOrder(IntPtr.Zero, windows);
} // }
}); });
getWindowDetailsThread.Name = "Retrieve window details"; getWindowDetailsThread.Name = "Retrieve window details";
getWindowDetailsThread.IsBackground = true; getWindowDetailsThread.IsBackground = true;

View file

@ -181,6 +181,11 @@ namespace GreenshotPlugin.Core {
private WindowDetails parent = null; private WindowDetails parent = null;
private bool frozen = false; private bool frozen = false;
public bool isMetroApp {
get;
set;
}
/// <summary> /// <summary>
/// The window handle. /// The window handle.
/// </summary> /// </summary>
@ -246,6 +251,10 @@ namespace GreenshotPlugin.Core {
/// </summary> /// </summary>
public Image DisplayIcon { public Image DisplayIcon {
get { get {
if (isMetroApp) {
// No method yet to get the metro icon
return null;
}
try { try {
string filename = ProcessPath; string filename = ProcessPath;
if (!iconCache.ContainsKey(filename)) { if (!iconCache.ContainsKey(filename)) {
@ -1320,7 +1329,8 @@ namespace GreenshotPlugin.Core {
public static List<WindowDetails> GetVisibleWindows() { public static List<WindowDetails> GetVisibleWindows() {
List<WindowDetails> windows = new List<WindowDetails>(); List<WindowDetails> windows = new List<WindowDetails>();
Rectangle screenBounds = WindowCapture.GetScreenBounds(); Rectangle screenBounds = WindowCapture.GetScreenBounds();
List<WindowDetails> allWindows = WindowDetails.GetAllWindows(); List<WindowDetails> allWindows = GetMetroApps();
allWindows.AddRange(WindowDetails.GetAllWindows());
foreach(WindowDetails window in allWindows) { foreach(WindowDetails window in allWindows) {
// Ignore windows without title // Ignore windows without title
if (window.Text.Length == 0) { if (window.Text.Length == 0) {
@ -1346,15 +1356,34 @@ namespace GreenshotPlugin.Core {
return windows; return windows;
} }
/// <summary>
/// Get the WindowDetails for all Metro Apps
/// These are all Windows with Classname "Windows.UI.Core.CoreWindow"
/// </summary>
/// <returns>List<WindowDetails> with visible metro apps</returns>
public static List<WindowDetails> GetMetroApps() {
List<WindowDetails> metroApps = new List<WindowDetails>();
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;
}
/// <summary> /// <summary>
/// Get all the top level windows /// Get all the top level windows
/// </summary> /// </summary>
/// <returns>List<WindowDetails> with all the top level windows</returns> /// <returns>List<WindowDetails> with all the top level windows</returns>
public static List<WindowDetails> GetTopLevelWindows() { public static List<WindowDetails> GetTopLevelWindows() {
List<WindowDetails> windows = new List<WindowDetails>(); List<WindowDetails> windows = new List<WindowDetails>();
Rectangle screenBounds = WindowCapture.GetScreenBounds(); var possibleTopLevelWindows = GetMetroApps();
List<WindowDetails> allWindows = WindowDetails.GetAllWindows(); possibleTopLevelWindows.AddRange(WindowDetails.GetAllWindows());
foreach (WindowDetails window in allWindows) { foreach (WindowDetails window in possibleTopLevelWindows) {
// Ignore windows without title // Ignore windows without title
if (window.Text.Length == 0) { if (window.Text.Length == 0) {
continue; continue;