mirror of
https://github.com/QL-Win/QuickLook.git
synced 2025-09-12 02:09:05 +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;
|
||||
}
|
||||
|
||||
// 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)
|
||||
{
|
||||
auto tId = GetWindowThreadProcessId(hwnd, nullptr);
|
||||
|
||||
GUITHREADINFO gui = {sizeof gui};
|
||||
GetGUIThreadInfo(tId, &gui);
|
||||
return gui.flags || gui.hwndCaret || IsListaryToolbarVisible();
|
||||
GUITHREADINFO gti = { sizeof gti };
|
||||
GetGUIThreadInfo(tId, >i);
|
||||
|
||||
return gti.flags || gti.hwndCaret || IsSearchBoxFocused() || IsListaryToolbarVisible();
|
||||
}
|
||||
|
||||
bool HelperMethods::IsUWP()
|
||||
@@ -108,3 +136,17 @@ bool HelperMethods::IsUWP()
|
||||
UINT32 pn = 0;
|
||||
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;
|
||||
}
|
||||
|
Reference in New Issue
Block a user