-
Notifications
You must be signed in to change notification settings - Fork 166
Add quick hide desktop icons.wh.cpp #2381
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Add quick hide desktop icons.wh.cpp #2381
Conversation
Add quick-hide-desktop-icons mod - Toggles desktop icon visibility with customizable mouse clicks (left/right/middle, single/double) or keyboard hotkeys - Supports English, Simplified Chinese, Traditional Chinese, and Japanese - Tested on Windows 11 24H2
Add quick-hide-desktop-icons mod - Toggles desktop icon visibility with customizable mouse clicks (left/right/middle, single/double) or keyboard hotkeys - Supports English, Simplified Chinese, Traditional Chinese, and Japanese - Tested on Windows 11 24H2
m417z
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the submission!
Fix some potential problems Make some adjustments to the optional configuration. Some new methods are referenced.
|
|
||
| if (defView) { | ||
| DWORD pid; | ||
| GetWindowThreadProcessId(defView, &pid); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It should be enough to check for the process id of one of the windows, e.g. shellWnd. All child windows are part of the same process.
| HWND defView = FindWindowExW(workerW, nullptr, L"SHELLDLL_DefView", nullptr); | ||
| HWND worker = g_lastWorkerW && IsWindow(g_lastWorkerW) ? g_lastWorkerW : nullptr; | ||
| DWORD start = GetTickCount(); | ||
| while ((worker = FindWindowExW(nullptr, worker, L"WorkerW", nullptr))) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It'd be better to add a delay in each iteration (e.g. use Sleep(20);) to avoid stressing the CPU unnecessarily.
| if (DispatchMessageW_Original) { | ||
| #ifdef Wh_RemoveFunctionHook | ||
| Wh_RemoveFunctionHook((void*)DispatchMessageW, (void*)DispatchMessageW_Hook); | ||
| #endif |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wh_RemoveFunctionHook is not a macro, so this #ifdef block will never be compiled. In addition, Wh_SetFunctionHook and Wh_RemoveFunctionHook don't have any effect until Wh_ApplyHookOperation is called, unless hooks are set in Wh_ModInit. Generally, it's recommended to set the hooks once in Wh_ModInit and then use them when needed, or just call the original function.
Refer to the documentation for details:
https://github.com/ramensoftware/windhawk/wiki/Creating-a-new-mod#wh_setfunctionhook
| if (DispatchMessageW_Original) { | ||
| #ifdef Wh_RemoveFunctionHook | ||
| Wh_RemoveFunctionHook((void*)DispatchMessageW, (void*)DispatchMessageW_Hook); | ||
| #endif |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hooks are removed automatically before Wh_ModUninit is called.
Add quick-hide-desktop-icons mod