Skip to content

Commit

Permalink
fix(shell): edit control
Browse files Browse the repository at this point in the history
  • Loading branch information
std-microblock committed Feb 4, 2025
1 parent ff186b5 commit 4c16f32
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/shell/script/binding_types_com.cc
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,13 @@ js_menu_context js_menu_context::$from_window(void *_hwnd) {

// Check if the foreground window is an edit control
char className[256];
auto activeWindowHandle = GetForegroundWindow();
auto activeWindowThread =
GetWindowThreadProcessId(activeWindowHandle, nullptr);
auto thisWindowThread = GetCurrentThreadId();
AttachThreadInput(activeWindowThread, thisWindowThread, true);
auto focused_hwnd = GetFocus();
AttachThreadInput(activeWindowThread, thisWindowThread, false);
if (GetClassNameA(focused_hwnd, className, sizeof(className))) {
std::string class_name = className;
std::printf("Focused window class name: %s\n", class_name.c_str());
Expand All @@ -174,10 +180,13 @@ js_menu_context js_menu_context::$from_window(void *_hwnd) {
(*event_data.input_box)->$hwnd = focused_hwnd;
return event_data;
}
}

if (GetClassNameA(hWnd, className, sizeof(className))) {
std::string class_name = className;
if (class_name == "SysListView32" || class_name == "DirectUIHWND" ||
class_name == "SHELLDLL_DefView" || class_name == "CabinetWClass") {
std::printf("Focused window is a folder view(hwnd: %p)\n", focused_hwnd);
std::printf("Target window is a folder view (hwnd: %p)\n", hWnd);
CoInitializeEx(NULL, COINIT_MULTITHREADED);
// Check if the foreground window is an Explorer window

Expand Down

0 comments on commit 4c16f32

Please sign in to comment.