mirror of
https://github.com/QL-Win/QuickLook.git
synced 2025-09-12 10:19:07 +00:00
Fix #579: also deal with non-English UIs
This commit is contained in:
@@ -90,29 +90,15 @@ bool HelperMethods::IsListaryToolbarVisible()
|
||||
|
||||
// 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()
|
||||
bool HelperMethods::IsExplorerSearchBoxFocused()
|
||||
{
|
||||
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;
|
||||
return wcscmp(classBuffer, L"Windows.UI.Core.CoreWindow") == 0;
|
||||
}
|
||||
|
||||
bool HelperMethods::IsCursorActivated(HWND hwnd)
|
||||
@@ -122,7 +108,7 @@ bool HelperMethods::IsCursorActivated(HWND hwnd)
|
||||
GUITHREADINFO gti = { sizeof gti };
|
||||
GetGUIThreadInfo(tId, >i);
|
||||
|
||||
return gti.flags || gti.hwndCaret || IsSearchBoxFocused() || IsListaryToolbarVisible();
|
||||
return gti.flags || gti.hwndCaret || IsListaryToolbarVisible();
|
||||
}
|
||||
|
||||
bool HelperMethods::IsUWP()
|
||||
|
@@ -22,10 +22,10 @@ public:
|
||||
static void GetSelectedInternal(CComQIPtr<IWebBrowserApp> pWebBrowserApp, PWCHAR buffer);
|
||||
static void ObtainFirstItem(CComPtr<IDataObject> dao, PWCHAR buffer);
|
||||
static bool IsCursorActivated(HWND hwndfg);
|
||||
static bool IsExplorerSearchBoxFocused();
|
||||
static bool HelperMethods::IsUWP();
|
||||
|
||||
private:
|
||||
static bool IsListaryToolbarVisible();
|
||||
static bool IsSearchBoxFocused();
|
||||
static HWND GetFocusedControl();
|
||||
};
|
||||
|
@@ -32,7 +32,7 @@ Shell32::FocusedWindowType Shell32::GetFocusedWindowType()
|
||||
if (HelperMethods::IsCursorActivated(hwndfg))
|
||||
return INVALID;
|
||||
|
||||
WCHAR classBuffer[MAX_PATH] = {'\0'};
|
||||
WCHAR classBuffer[MAX_PATH] = { '\0' };
|
||||
if (FAILED(GetClassName(hwndfg, classBuffer, MAX_PATH)))
|
||||
return INVALID;
|
||||
|
||||
@@ -53,13 +53,19 @@ Shell32::FocusedWindowType Shell32::GetFocusedWindowType()
|
||||
}
|
||||
if (wcscmp(classBuffer, L"ExploreWClass") == 0 || wcscmp(classBuffer, L"CabinetWClass") == 0)
|
||||
{
|
||||
return EXPLORER;
|
||||
if (!HelperMethods::IsExplorerSearchBoxFocused())
|
||||
{
|
||||
return EXPLORER;
|
||||
}
|
||||
}
|
||||
if (wcscmp(classBuffer, L"#32770") == 0)
|
||||
{
|
||||
if (FindWindowEx(hwndfg, nullptr, L"DUIViewWndClassName", nullptr) != nullptr)
|
||||
{
|
||||
return DIALOG;
|
||||
if (!HelperMethods::IsExplorerSearchBoxFocused())
|
||||
{
|
||||
return DIALOG;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user