Last active
August 15, 2023 13:01
-
-
Save rbmm/649efd3f332ac38a71c0566ef0f332d0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void MinimizeAll(_In_ BOOL bDialogsToo, _In_opt_ HWND hwndMy = 0) | |
{ | |
if (HWND hwnd = FindWindowW(L"Shell_TrayWnd", 0)) | |
{ | |
ULONG dwProcessId; | |
if (GetWindowThreadProcessId(hwnd, &dwProcessId)) | |
{ | |
AllowSetForegroundWindow(dwProcessId); | |
//WCHAR name[0x100]; | |
//if (HMODULE hmod = LoadLibraryExW(L"taskbar.dll", 0, LOAD_LIBRARY_AS_IMAGE_RESOURCE)) | |
//{ | |
// LoadStringW(hmod, 0x252, name, _countof(name)); | |
// FreeLibrary(hmod); | |
//} | |
HWND hWndChild = 0; | |
while (hWndChild = FindWindowExW(hwnd, hWndChild, REBARCLASSNAMEW, 0)) | |
{ | |
if (HWND hwndTask = FindWindowEx(hWndChild, 0, L"MSTaskSwWClass", 0 /*name*/)) | |
{ | |
if (HANDLE hProcess = OpenProcess(PROCESS_DUP_HANDLE, FALSE, dwProcessId)) | |
{ | |
if (HANDLE hEvent = CreateEvent(0, 0, 0, 0)) | |
{ | |
HANDLE hRemoteEvent; | |
if (DuplicateHandle(GetCurrentProcess(), hEvent, hProcess, &hRemoteEvent, 0, 0, DUPLICATE_SAME_ACCESS)) | |
{ | |
if (PostMessageW(hwndTask, 0x435, (WPARAM)hRemoteEvent, bDialogsToo)) | |
{ | |
ULONG n; | |
while (1 == (n = MsgWaitForMultipleObjectsEx(1, &hEvent, 2000, QS_ALLINPUT, MWMO_INPUTAVAILABLE))) | |
{ | |
MSG msg; | |
while (PeekMessageW(&msg, 0, 0, 0, PM_REMOVE)) | |
{ | |
DispatchMessageW(&msg); | |
} | |
} | |
if (WAIT_OBJECT_0 != n) | |
{ | |
DbgPrint("%x Fail !!\n", n); | |
} | |
} | |
DuplicateHandle(hProcess, hRemoteEvent, 0, 0, 0, 0, DUPLICATE_CLOSE_SOURCE); | |
} | |
CloseHandle(hEvent); | |
} | |
CloseHandle(hProcess); | |
} | |
break; | |
} | |
} | |
} | |
} | |
if (hwndMy) SetWindowPos(hwndMy, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOSIZE|SWP_NOMOVE); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment