From 1d83cd8dd0483cd2b892b0b7d1272cf65b9e7f3a Mon Sep 17 00:00:00 2001 From: Paddy Xu Date: Mon, 23 Sep 2019 20:06:31 +0300 Subject: [PATCH 1/3] Fix #521: wrong path copying when Enter key is pressed and QL is *not* showing --- QuickLook/BackgroundListener.cs | 10 ++++++---- QuickLook/ViewWindowManager.cs | 23 ++++++++++++----------- 2 files changed, 18 insertions(+), 15 deletions(-) diff --git a/QuickLook/BackgroundListener.cs b/QuickLook/BackgroundListener.cs index c90899f..6a2b644 100644 --- a/QuickLook/BackgroundListener.cs +++ b/QuickLook/BackgroundListener.cs @@ -75,33 +75,35 @@ namespace QuickLook private void InvokeRoutine(Keys key, bool isKeyDown) { - var path = NativeMethods.QuickLook.GetCurrentSelection(); - Debug.WriteLine($"InvokeRoutine: key={key},down={isKeyDown}"); if (isKeyDown) + { switch (key) { case Keys.Enter: PipeServerManager.SendMessage(PipeMessages.RunAndClose); break; } + } else + { switch (key) { case Keys.Up: case Keys.Down: case Keys.Left: case Keys.Right: - PipeServerManager.SendMessage(PipeMessages.Switch, path); + PipeServerManager.SendMessage(PipeMessages.Switch); break; case Keys.Space: - PipeServerManager.SendMessage(PipeMessages.Toggle, path); + PipeServerManager.SendMessage(PipeMessages.Toggle); break; case Keys.Escape: PipeServerManager.SendMessage(PipeMessages.Close); break; } + } } private void InstallKeyHook(KeyEventHandler downHandler, KeyEventHandler upHandler) diff --git a/QuickLook/ViewWindowManager.cs b/QuickLook/ViewWindowManager.cs index 0ab1a6a..0c89e3d 100644 --- a/QuickLook/ViewWindowManager.cs +++ b/QuickLook/ViewWindowManager.cs @@ -73,8 +73,11 @@ namespace QuickLook _viewerWindow.BeginHide(); } - public void TogglePreview(string path) + public void TogglePreview(string path = null) { + if (string.IsNullOrEmpty(path)) + path = NativeMethods.QuickLook.GetCurrentSelection(); + if (_viewerWindow.Visibility == Visibility.Visible && (string.IsNullOrEmpty(path) || path == _invokedPath)) ClosePreview(); else @@ -99,19 +102,14 @@ namespace QuickLook var newWindow = new ViewerWindow(); - /*if (_viewerWindow.WindowState != WindowState.Maximized) - { - newWindow.Top = _viewerWindow.Top; - newWindow.Left = _viewerWindow.Left; - newWindow.Width = _viewerWindow.Width; - newWindow.Height = _viewerWindow.Height; - }*/ - _viewerWindow = newWindow; } - public void SwitchPreview(string path) + public void SwitchPreview(string path = null) { + if (string.IsNullOrEmpty(path)) + path = NativeMethods.QuickLook.GetCurrentSelection(); + if (string.IsNullOrEmpty(path)) return; @@ -121,8 +119,11 @@ namespace QuickLook InvokePreview(path); } - public void InvokePreview(string path) + public void InvokePreview(string path = null) { + if (string.IsNullOrEmpty(path)) + path = NativeMethods.QuickLook.GetCurrentSelection(); + if (string.IsNullOrEmpty(path)) return; From 8549f24d0ac77bb47fb5fd9779e2ee44e86b5d29 Mon Sep 17 00:00:00 2001 From: Paddy Xu Date: Mon, 23 Sep 2019 20:26:27 +0300 Subject: [PATCH 2/3] Fix #521 again: the same for arrow keys --- QuickLook/ViewWindowManager.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/QuickLook/ViewWindowManager.cs b/QuickLook/ViewWindowManager.cs index 0c89e3d..6e9f463 100644 --- a/QuickLook/ViewWindowManager.cs +++ b/QuickLook/ViewWindowManager.cs @@ -107,15 +107,15 @@ namespace QuickLook public void SwitchPreview(string path = null) { + if (_viewerWindow.Visibility != Visibility.Visible) + return; + if (string.IsNullOrEmpty(path)) path = NativeMethods.QuickLook.GetCurrentSelection(); if (string.IsNullOrEmpty(path)) return; - if (_viewerWindow.Visibility != Visibility.Visible) - return; - InvokePreview(path); } From cb0005118c1c0376c633a1abe83ab758004f4742 Mon Sep 17 00:00:00 2001 From: Paddy Xu Date: Wed, 25 Sep 2019 21:25:54 +0300 Subject: [PATCH 3/3] Everything executes selected items from another (hidden) window (ref #521) --- QuickLook.Native/QuickLook.Native32/Shell32.cpp | 2 +- QuickLook/NativeMethods/QuickLook.cs | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/QuickLook.Native/QuickLook.Native32/Shell32.cpp b/QuickLook.Native/QuickLook.Native32/Shell32.cpp index 38dcccc..707938e 100644 --- a/QuickLook.Native/QuickLook.Native32/Shell32.cpp +++ b/QuickLook.Native/QuickLook.Native32/Shell32.cpp @@ -40,7 +40,7 @@ Shell32::FocusedWindowType Shell32::GetFocusedWindowType() { return DOPUS; } - if (wcscmp(classBuffer, L"EVERYTHING") == 0) + if (wcscmp(classBuffer, L"EVERYTHING") == 0 || wcscmp(classBuffer, L"EVERYTHING_SHELL_EXECUTE") == 0) { return EVERYTHING; } diff --git a/QuickLook/NativeMethods/QuickLook.cs b/QuickLook/NativeMethods/QuickLook.cs index fe416d9..0a6b1f0 100644 --- a/QuickLook/NativeMethods/QuickLook.cs +++ b/QuickLook/NativeMethods/QuickLook.cs @@ -107,7 +107,9 @@ namespace QuickLook.NativeMethods Invalid, Desktop, Explorer, - Dialog + Dialog, + Everything, + DOpus } } } \ No newline at end of file