mirror of
https://github.com/QL-Win/QuickLook.git
synced 2025-12-24 02:00:55 +08:00
Close window also when focusing on viewer
This commit is contained in:
@@ -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)
|
||||
{
|
||||
|
||||
@@ -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 =
|
||||
|
||||
@@ -18,7 +18,8 @@ namespace QuickLook
|
||||
internal void InvokeRoutine()
|
||||
{
|
||||
if (!WindowHelper.IsFocusedControlExplorerItem())
|
||||
return;
|
||||
if (!WindowHelper.IsFocusedWindowSelf())
|
||||
return;
|
||||
|
||||
if (CloseCurrentWindow())
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user