mirror of
https://github.com/QL-Win/QuickLook.git
synced 2025-09-12 18:39:45 +00:00
Fix #579: search box changed in Windows 10 1909
This commit is contained in:
@@ -88,13 +88,41 @@ bool HelperMethods::IsListaryToolbarVisible()
|
|||||||
return found;
|
return found;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Windows 10 1909 replaced the search box in the File Explorer by a UWP control.
|
||||||
|
// gti.flags is always 0 for UWP applications.
|
||||||
|
bool HelperMethods::IsSearchBoxFocused()
|
||||||
|
{
|
||||||
|
WCHAR wClassBuffer[MAX_PATH] = { '\0' };
|
||||||
|
if (FAILED(GetClassName(GetForegroundWindow(), wClassBuffer, MAX_PATH)))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (wcscmp(wClassBuffer, L"ExploreWClass") != 0 && wcscmp(wClassBuffer, L"CabinetWClass") != 0)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
auto* hwnd = GetFocusedControl();
|
||||||
|
|
||||||
|
WCHAR classBuffer[MAX_PATH] = { '\0' };
|
||||||
|
if (FAILED(GetClassName(hwnd, classBuffer, MAX_PATH)))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (wcscmp(classBuffer, L"Windows.UI.Core.CoreWindow") != 0)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
WCHAR textBuffer[MAX_PATH] = { '\0' };
|
||||||
|
if (FAILED(GetWindowText(hwnd, textBuffer, MAX_PATH)))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return wcscmp(textBuffer, L"Cortana") == 0;
|
||||||
|
}
|
||||||
|
|
||||||
bool HelperMethods::IsCursorActivated(HWND hwnd)
|
bool HelperMethods::IsCursorActivated(HWND hwnd)
|
||||||
{
|
{
|
||||||
auto tId = GetWindowThreadProcessId(hwnd, nullptr);
|
auto tId = GetWindowThreadProcessId(hwnd, nullptr);
|
||||||
|
|
||||||
GUITHREADINFO gui = {sizeof gui};
|
GUITHREADINFO gti = { sizeof gti };
|
||||||
GetGUIThreadInfo(tId, &gui);
|
GetGUIThreadInfo(tId, >i);
|
||||||
return gui.flags || gui.hwndCaret || IsListaryToolbarVisible();
|
|
||||||
|
return gti.flags || gti.hwndCaret || IsSearchBoxFocused() || IsListaryToolbarVisible();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool HelperMethods::IsUWP()
|
bool HelperMethods::IsUWP()
|
||||||
@@ -108,3 +136,17 @@ bool HelperMethods::IsUWP()
|
|||||||
UINT32 pn = 0;
|
UINT32 pn = 0;
|
||||||
return pGCPFN(&pn, nullptr) == ERROR_INSUFFICIENT_BUFFER;
|
return pGCPFN(&pn, nullptr) == ERROR_INSUFFICIENT_BUFFER;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
HWND HelperMethods::GetFocusedControl()
|
||||||
|
{
|
||||||
|
auto tid = GetWindowThreadProcessId(GetForegroundWindow(), nullptr);
|
||||||
|
|
||||||
|
if (0 == AttachThreadInput(GetCurrentThreadId(), tid, TRUE))
|
||||||
|
return nullptr;
|
||||||
|
|
||||||
|
auto* hwnd = GetFocus();
|
||||||
|
|
||||||
|
AttachThreadInput(GetCurrentThreadId(), tid, FALSE);
|
||||||
|
|
||||||
|
return hwnd;
|
||||||
|
}
|
||||||
|
@@ -26,4 +26,6 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
static bool IsListaryToolbarVisible();
|
static bool IsListaryToolbarVisible();
|
||||||
|
static bool IsSearchBoxFocused();
|
||||||
|
static HWND GetFocusedControl();
|
||||||
};
|
};
|
||||||
|
Reference in New Issue
Block a user