Everything support

This commit is contained in:
Paddy Xu
2017-06-15 21:08:24 +03:00
parent c1b17bb756
commit bda5a38df1
10 changed files with 121 additions and 16 deletions

View File

@@ -32,7 +32,7 @@ static WCHAR filePathBuffer[MAX_PATH] = {'\0'};
#define SHARED_MEM_NAME L"QUICKLOOK_WOW64HOOKHELPER_MEM"
void DialogHook::GetSelectedFromCommonDialog(PWCHAR buffer)
void DialogHook::GetSelected(PWCHAR buffer)
{
auto hwndfg = GetForegroundWindow();
DWORD pid = 0;
@@ -67,7 +67,7 @@ void DialogHook::GetSelectedFromCommonDialog(PWCHAR buffer)
return;
SendMessage(hwndfg, WM_HOOK_NOTIFY, 0, 0);
wcscpy_s(buffer, wcslen(buffer) - 1, filePathBuffer);
wcscpy_s(buffer, MAX_PATH, filePathBuffer);
}
}

View File

@@ -19,7 +19,7 @@
class DialogHook
{
public:
static void GetSelectedFromCommonDialog(PWCHAR buffer);
static void GetSelected(PWCHAR buffer);
private:
static void getSelectedInternal(CComPtr<IShellBrowser> psb, PWCHAR buffer);

View File

@@ -0,0 +1,61 @@
// Copyright <20> 2017 Paddy Xu
//
// This file is part of QuickLook program.
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
#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),
WM_COMMAND,
MAKEWPARAM(EVERYTHING_IPC_ID_FILE_COPY_FULL_PATH_AND_NAME, 0),
0))
return;
if (!OpenClipboard(nullptr))
return;
auto hData = GetClipboardData(CF_UNICODETEXT);
if (hData == nullptr)
return;
auto pText = static_cast<PWCHAR>(GlobalLock(hData));
if (pText == nullptr)
return;
auto p = wcsstr(pText, L"\r\n");
auto l = p == nullptr ? wcslen(pText) : p - pText;
wcsncpy_s(buffer, MAX_PATH, pText, l);
GlobalUnlock(hData);
CloseClipboard();
}
void Everything::backupClipboard()
{
// TODO
}
void Everything::restoreClipboard()
{
// TODO
}

View File

@@ -0,0 +1,27 @@
// Copyright <20> 2017 Paddy Xu
//
// This file is part of QuickLook program.
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
#pragma once
class Everything
{
public:
static void GetSelected(PWCHAR buffer);
private:
static void backupClipboard();
static void restoreClipboard();
};

View File

@@ -83,6 +83,7 @@
</ItemDefinitionGroup>
<ItemGroup>
<ClInclude Include="DialogHook.h" />
<ClInclude Include="Everything.h" />
<ClInclude Include="HelperMethods.h" />
<ClInclude Include="WoW64HookHelper.h" />
<ClInclude Include="Shell32.h" />
@@ -99,6 +100,7 @@
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
</PrecompiledHeader>
</ClCompile>
<ClCompile Include="Everything.cpp" />
<ClCompile Include="HelperMethods.cpp" />
<ClCompile Include="DllExport.cpp" />
<ClCompile Include="Shell32.cpp" />

View File

@@ -33,6 +33,9 @@
<ClInclude Include="HelperMethods.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="Everything.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="stdafx.cpp">
@@ -56,5 +59,8 @@
<ClCompile Include="DllExport.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="Everything.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
</Project>

View File

@@ -20,13 +20,12 @@
#include "Shell32.h"
#include "HelperMethods.h"
#include "DialogHook.h"
#include "Everything.h"
using namespace std;
Shell32::FocusedWindowType Shell32::GetFocusedWindowType()
{
auto type = INVALID;
auto hwndfg = GetForegroundWindow();
if (HelperMethods::IsCursorActivated(hwndfg))
@@ -35,27 +34,31 @@ Shell32::FocusedWindowType Shell32::GetFocusedWindowType()
WCHAR classBuffer[MAX_PATH] = {'\0'};
if (SUCCEEDED(GetClassName(hwndfg, classBuffer, MAX_PATH)))
{
if (wcscmp(classBuffer, L"EVERYTHING") == 0)
{
return EVERYTHING;
}
if (wcscmp(classBuffer, L"WorkerW") == 0 || wcscmp(classBuffer, L"Progman") == 0)
{
if (FindWindowEx(hwndfg, nullptr, L"SHELLDLL_DefView", nullptr) != nullptr)
{
type = DESKTOP;
return DESKTOP;
}
}
else if (wcscmp(classBuffer, L"ExploreWClass") == 0 || wcscmp(classBuffer, L"CabinetWClass") == 0)
if (wcscmp(classBuffer, L"ExploreWClass") == 0 || wcscmp(classBuffer, L"CabinetWClass") == 0)
{
type = EXPLORER;
return EXPLORER;
}
else if (wcscmp(classBuffer, L"#32770") == 0)
if (wcscmp(classBuffer, L"#32770") == 0)
{
if (FindWindowEx(hwndfg, nullptr, L"DUIViewWndClassName", nullptr) != nullptr)
{
type = DIALOG;
return DIALOG;
}
}
}
return type;
return INVALID;
}
void Shell32::GetCurrentSelection(PWCHAR buffer)
@@ -69,7 +72,10 @@ void Shell32::GetCurrentSelection(PWCHAR buffer)
getSelectedFromExplorer(buffer);
break;
case DIALOG:
DialogHook::GetSelectedFromCommonDialog(buffer);
DialogHook::GetSelected(buffer);
break;
case EVERYTHING:
Everything::GetSelected(buffer);
break;
default:
break;

View File

@@ -24,10 +24,11 @@ class Shell32
public:
enum FocusedWindowType
{
INVALID = 0,
DESKTOP = 1,
EXPLORER = 2,
DIALOG = 3,
INVALID,
DESKTOP,
EXPLORER,
DIALOG,
EVERYTHING,
};
static FocusedWindowType GetFocusedWindowType();