Close window also when focusing on viewer

This commit is contained in:
Paddy Xu
2017-05-08 00:56:33 +03:00
parent 073b1df8a3
commit 43ba30f4d0
3 changed files with 13 additions and 3 deletions

View File

@@ -10,7 +10,8 @@ namespace QuickLook
/// </summary>
public partial class App : Application
{
public static string AppPath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
public static readonly string AppFullPath = Assembly.GetExecutingAssembly().Location;
public static readonly string AppPath = Path.GetDirectoryName(AppFullPath);
protected override void OnStartup(StartupEventArgs e)
{

View File

@@ -1,4 +1,5 @@
using System;
using System.IO;
using System.Text;
using System.Windows.Interop;
using QuickLook.NativeMethods;
@@ -41,10 +42,17 @@ namespace QuickLook.Helpers
return focusedControlHandle;
}
internal static bool IsFocusedWindowSelf()
{
var focusedWindowClass = GetWindowClassName(GetFocusedWindow());
return focusedWindowClass.StartsWith($"HwndWrapper[{Path.GetFileName(App.AppFullPath)};;");
}
internal static bool IsFocusedControlExplorerItem()
{
if (NativeMethods.QuickLook.GetFocusedWindowType() == 0)
return false;
return false;
var focusedWindowClass = GetWindowClassName(GetFocusedWindow());
var focusedWindowParentClass =

View File

@@ -18,7 +18,8 @@ namespace QuickLook
internal void InvokeRoutine()
{
if (!WindowHelper.IsFocusedControlExplorerItem())
return;
if (!WindowHelper.IsFocusedWindowSelf())
return;
if (CloseCurrentWindow())
return;