mirror of
https://github.com/QL-Win/QuickLook.git
synced 2025-09-14 12:19:08 +00:00
Fix for Everything v1.5(a) and later. Supports both v1.4 and v1.5. Turning off alpha_instance is no longer necessary. Also fixes a bug which crashes QuickLook when the path returned by client program is quoted.
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
// Copyright © 2017 Paddy Xu
|
||||
// Copyright © 2017 Paddy Xu
|
||||
//
|
||||
// This file is part of QuickLook program.
|
||||
//
|
||||
@@ -18,17 +18,32 @@
|
||||
#include "stdafx.h"
|
||||
#include "Everything.h"
|
||||
|
||||
#define EVERYTHING_IPC_SEARCH_CLIENT_WNDCLASSW L"EVERYTHING"
|
||||
#define EVERYTHING_IPC_ID_FILE_COPY_FULL_PATH_AND_NAME 41007
|
||||
|
||||
void Everything::GetSelected(PWCHAR buffer)
|
||||
{
|
||||
if (SendMessage(
|
||||
FindWindow(EVERYTHING_IPC_SEARCH_CLIENT_WNDCLASSW, nullptr),
|
||||
auto hWinFG = GetForegroundWindow();
|
||||
|
||||
// Everything v1.5 IPC via hidden window.
|
||||
HWND hWinI = FindWindowExW(hWinFG, NULL, EVERYTHING_IPC_HIDDEN_WIN_CLASS, NULL);
|
||||
|
||||
if (hWinI != nullptr) {
|
||||
int pLength = GetWindowTextLength(hWinI);
|
||||
wchar_t* pText = new wchar_t[pLength + 1];
|
||||
GetWindowText(hWinI, pText, pLength + 1);
|
||||
wcsncpy_s(buffer, MAX_PATH_EX, pText, pLength);
|
||||
return; // Success. Clipboard access unnecessary.
|
||||
}
|
||||
|
||||
HWND hWin = FindWindowW(EVERYTHING_IPC_WINDOW_CLASS, NULL);
|
||||
|
||||
if (hWin != nullptr) {
|
||||
// Everything IPC Clipboard
|
||||
SendMessageW(
|
||||
hWin,
|
||||
WM_COMMAND,
|
||||
MAKEWPARAM(EVERYTHING_IPC_ID_FILE_COPY_FULL_PATH_AND_NAME, 0),
|
||||
0))
|
||||
return;
|
||||
MAKEWPARAM(EVERYTHING_IPC_COPY_TO_CLIPBOARD, 0),
|
||||
0);
|
||||
|
||||
Sleep(100);
|
||||
|
||||
if (!OpenClipboard(nullptr))
|
||||
return;
|
||||
@@ -46,9 +61,18 @@ void Everything::GetSelected(PWCHAR buffer)
|
||||
wcsncpy_s(buffer, MAX_PATH_EX, pText, l); // Everything supports Long Path
|
||||
|
||||
GlobalUnlock(hData);
|
||||
|
||||
CloseClipboard();
|
||||
}
|
||||
}
|
||||
|
||||
bool Everything::MatchClass(PWCHAR classBuffer)
|
||||
{
|
||||
WCHAR sMatchC[256] = { '\0' };
|
||||
WCHAR sMatchS[256] = EVERYTHING_IPC_WINDOW_CLASS;
|
||||
int iLen = wcslen(sMatchS);
|
||||
wcsncpy_s(sMatchC, classBuffer, iLen);
|
||||
return (0 == wcscmp(sMatchC, sMatchS));
|
||||
}
|
||||
|
||||
void Everything::backupClipboard()
|
||||
{
|
||||
|
@@ -15,11 +15,16 @@
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
#define EVERYTHING_IPC_HIDDEN_WIN_CLASS L"EVERYTHING_RESULT_LIST_FOCUS"
|
||||
#define EVERYTHING_IPC_WINDOW_CLASS L"EVERYTHING"
|
||||
#define EVERYTHING_IPC_COPY_TO_CLIPBOARD 41007
|
||||
|
||||
#pragma once
|
||||
class Everything
|
||||
{
|
||||
public:
|
||||
static void GetSelected(PWCHAR buffer);
|
||||
static bool MatchClass(PWCHAR classBuffer);
|
||||
|
||||
private:
|
||||
static void backupClipboard();
|
||||
|
@@ -40,7 +40,7 @@ Shell32::FocusedWindowType Shell32::GetFocusedWindowType()
|
||||
{
|
||||
return DOPUS;
|
||||
}
|
||||
if (wcscmp(classBuffer, L"EVERYTHING") == 0 || wcscmp(classBuffer, L"EVERYTHING_SHELL_EXECUTE") == 0)
|
||||
if (Everything::MatchClass(classBuffer))
|
||||
{
|
||||
return EVERYTHING;
|
||||
}
|
||||
|
@@ -103,7 +103,12 @@ namespace QuickLook.NativeMethods
|
||||
thread.SetApartmentState(ApartmentState.STA);
|
||||
thread.Start();
|
||||
thread.Join();
|
||||
return ResolveShortcut(sb?.ToString() ?? string.Empty);
|
||||
if(sb.Length > 2 && sb[0].Equals('"') && sb[sb.Length-1].Equals('"'))
|
||||
{
|
||||
// We got a quoted string which breaks ResolveShortcut
|
||||
sb = sb.Replace("\"", "", 0, 1).Replace("\"", "", sb.Length-1, 1);
|
||||
}
|
||||
return ResolveShortcut(sb?.ToString() ?? String.Empty);
|
||||
}
|
||||
|
||||
private static string ResolveShortcut(string path)
|
||||
|
Reference in New Issue
Block a user