mirror of
https://github.com/valinet/ExplorerPatcher.git
synced 2024-11-28 01:10:55 +01:00
Option to toggle taskbar autohide on taskbar double click now works with Windows 11 taskbar
This commit is contained in:
parent
2732c6160c
commit
7649c43d03
@ -1449,7 +1449,7 @@ HMENU explorer_LoadMenuW(HINSTANCE hInstance, LPCWSTR lpMenuName)
|
||||
|
||||
HHOOK Shell_TrayWndMouseHook = NULL;
|
||||
|
||||
BOOL Shell_TrayWnd_IsTaskbarRightClick(POINT pt)
|
||||
BOOL IsPointOnEmptyAreaOfNewTaskbar(POINT pt)
|
||||
{
|
||||
HRESULT hr = S_OK;
|
||||
IUIAutomation2* pIUIAutomation2 = NULL;
|
||||
@ -1561,13 +1561,19 @@ BOOL Shell_TrayWnd_IsTaskbarRightClick(POINT pt)
|
||||
return bRet;
|
||||
}
|
||||
|
||||
long long TaskbarLeftClickTime = 0;
|
||||
BOOL bTaskbarLeftClickEven = FALSE;
|
||||
LRESULT CALLBACK Shell_TrayWndMouseProc(
|
||||
_In_ int nCode,
|
||||
_In_ WPARAM wParam,
|
||||
_In_ LPARAM lParam
|
||||
)
|
||||
{
|
||||
if (nCode == HC_ACTION && wParam == WM_RBUTTONUP && Shell_TrayWnd_IsTaskbarRightClick(((MOUSEHOOKSTRUCT*)lParam)->pt))
|
||||
if (!bOldTaskbar &&
|
||||
nCode == HC_ACTION &&
|
||||
wParam == WM_RBUTTONUP &&
|
||||
IsPointOnEmptyAreaOfNewTaskbar(((MOUSEHOOKSTRUCT*)lParam)->pt)
|
||||
)
|
||||
{
|
||||
PostMessageW(
|
||||
FindWindowW(L"Shell_TrayWnd", NULL),
|
||||
@ -1577,6 +1583,46 @@ LRESULT CALLBACK Shell_TrayWndMouseProc(
|
||||
);
|
||||
return 1;
|
||||
}
|
||||
if (!bOldTaskbar &&
|
||||
bTaskbarAutohideOnDoubleClick &&
|
||||
nCode == HC_ACTION &&
|
||||
wParam == WM_LBUTTONUP &&
|
||||
IsPointOnEmptyAreaOfNewTaskbar(((MOUSEHOOKSTRUCT*)lParam)->pt)
|
||||
)
|
||||
{
|
||||
/*BOOL bShouldCheck = FALSE;
|
||||
if (bOldTaskbar)
|
||||
{
|
||||
WCHAR cn[200];
|
||||
GetClassNameW(((MOUSEHOOKSTRUCT*)lParam)->hwnd, cn, 200);
|
||||
wprintf(L"%s\n", cn);
|
||||
bShouldCheck = !wcscmp(cn, L"Shell_SecondaryTrayWnd"); // !wcscmp(cn, L"Shell_TrayWnd")
|
||||
}
|
||||
else
|
||||
{
|
||||
bShouldCheck = IsPointOnEmptyAreaOfNewTaskbar(((MOUSEHOOKSTRUCT*)lParam)->pt);
|
||||
}
|
||||
if (bShouldCheck)
|
||||
{*/
|
||||
if (bTaskbarLeftClickEven)
|
||||
{
|
||||
if (TaskbarLeftClickTime != 0)
|
||||
{
|
||||
TaskbarLeftClickTime = milliseconds_now() - TaskbarLeftClickTime;
|
||||
}
|
||||
if (TaskbarLeftClickTime != 0 && TaskbarLeftClickTime < GetDoubleClickTime())
|
||||
{
|
||||
TaskbarLeftClickTime = 0;
|
||||
ToggleTaskbarAutohide();
|
||||
}
|
||||
else
|
||||
{
|
||||
TaskbarLeftClickTime = milliseconds_now();
|
||||
}
|
||||
}
|
||||
bTaskbarLeftClickEven = !bTaskbarLeftClickEven;
|
||||
//}
|
||||
}
|
||||
return CallNextHookEx(Shell_TrayWndMouseHook, nCode, wParam, lParam);
|
||||
}
|
||||
|
||||
@ -1593,6 +1639,7 @@ INT64 Shell_TrayWndSubclassProc(
|
||||
{
|
||||
if (bIsPrimaryTaskbar)
|
||||
{
|
||||
UnhookWindowsHookEx(Shell_TrayWndMouseHook);
|
||||
UnregisterHotKey(hWnd, 'VNEP');
|
||||
}
|
||||
RemoveWindowSubclass(hWnd, Shell_TrayWndSubclassProc, Shell_TrayWndSubclassProc);
|
||||
@ -1610,20 +1657,10 @@ INT64 Shell_TrayWndSubclassProc(
|
||||
// Received when mouse is over taskbar edge and autohide is on
|
||||
PostMessageW(hWnd, WM_ACTIVATE, WA_ACTIVE, NULL);
|
||||
}
|
||||
else if (uMsg == WM_LBUTTONDBLCLK && bTaskbarAutohideOnDoubleClick)
|
||||
else if (bOldTaskbar && uMsg == WM_LBUTTONDBLCLK && bTaskbarAutohideOnDoubleClick)
|
||||
{
|
||||
APPBARDATA abd;
|
||||
abd.cbSize = sizeof(APPBARDATA);
|
||||
if (SHAppBarMessage(ABM_GETSTATE, &abd) == ABS_AUTOHIDE)
|
||||
{
|
||||
abd.lParam = 0;
|
||||
SHAppBarMessage(ABM_SETSTATE, &abd);
|
||||
}
|
||||
else
|
||||
{
|
||||
abd.lParam = ABS_AUTOHIDE;
|
||||
SHAppBarMessage(ABM_SETSTATE, &abd);
|
||||
}
|
||||
ToggleTaskbarAutohide();
|
||||
return 0;
|
||||
}
|
||||
else if (uMsg == WM_HOTKEY && lParam == MAKELPARAM(MOD_WIN | MOD_ALT, 0x44))
|
||||
{
|
||||
@ -1649,11 +1686,11 @@ INT64 Shell_TrayWndSubclassProc(
|
||||
{
|
||||
UpdateStartMenuPositioning(MAKELPARAM(TRUE, FALSE));
|
||||
}
|
||||
else if (!bOldTaskbar && uMsg == WM_PARENTNOTIFY && wParam == WM_RBUTTONDOWN && !Shell_TrayWndMouseHook) // && !IsUndockingDisabled
|
||||
{
|
||||
DWORD dwThreadId = GetCurrentThreadId();
|
||||
Shell_TrayWndMouseHook = SetWindowsHookExW(WH_MOUSE, Shell_TrayWndMouseProc, NULL, dwThreadId);
|
||||
}
|
||||
//else if (!bOldTaskbar && uMsg == WM_PARENTNOTIFY && wParam == WM_RBUTTONDOWN && !Shell_TrayWndMouseHook) // && !IsUndockingDisabled
|
||||
//{
|
||||
// DWORD dwThreadId = GetCurrentThreadId();
|
||||
// Shell_TrayWndMouseHook = SetWindowsHookExW(WH_MOUSE, Shell_TrayWndMouseProc, NULL, dwThreadId);
|
||||
//}
|
||||
else if (uMsg == RegisterWindowMessageW(L"Windows11ContextMenu_" _T(EP_CLSID)))
|
||||
{
|
||||
POINT pt;
|
||||
@ -4804,6 +4841,7 @@ HWND CreateWindowExWHook(
|
||||
{
|
||||
SetWindowSubclass(hWnd, Shell_TrayWndSubclassProc, Shell_TrayWndSubclassProc, TRUE);
|
||||
RegisterHotKey(hWnd, 'VNEP', MOD_WIN | MOD_ALT, 0x44);
|
||||
Shell_TrayWndMouseHook = SetWindowsHookExW(WH_MOUSE, Shell_TrayWndMouseProc, NULL, GetCurrentThreadId());
|
||||
}
|
||||
else if (bIsExplorerProcess && (*((WORD*)&(lpClassName)+1)) && !wcscmp(lpClassName, L"Shell_SecondaryTrayWnd"))
|
||||
{
|
||||
|
@ -350,8 +350,6 @@
|
||||
"LastSectionInProperties"=dword:00000000
|
||||
;b Open clock flyout when pressing Win+C instead of Microsoft Teams
|
||||
"ClockFlyoutOnWinC"=dword:00000000
|
||||
;b Toggle Windows 10 taskbar auto-hide by double clicking on the main taskbar
|
||||
"TaskbarAutohideOnDoubleClick"=dword:00000000
|
||||
;b Show separators between taskbar toolbars *
|
||||
"ToolbarSeparators"=dword:00000000
|
||||
[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced]
|
||||
@ -413,6 +411,8 @@
|
||||
"AllocConsole"=dword:00000000
|
||||
;b Dump memory leaks
|
||||
"Memcheck"=dword:00000000
|
||||
;b Double click taskbar to toggle auto-hide (only works when the taskbar is locked)
|
||||
"TaskbarAutohideOnDoubleClick"=dword:00000000
|
||||
[HKEY_CURRENT_USER\Control Panel\Desktop]
|
||||
;b Show Windows build info on the desktop *
|
||||
"PaintDesktopversion"=dword:00000000
|
||||
|
@ -638,3 +638,19 @@ HRESULT ShellExecuteFromExplorer(
|
||||
}
|
||||
return hr;
|
||||
}
|
||||
|
||||
void ToggleTaskbarAutohide()
|
||||
{
|
||||
APPBARDATA abd;
|
||||
abd.cbSize = sizeof(APPBARDATA);
|
||||
if (SHAppBarMessage(ABM_GETSTATE, &abd) == ABS_AUTOHIDE)
|
||||
{
|
||||
abd.lParam = 0;
|
||||
SHAppBarMessage(ABM_SETSTATE, &abd);
|
||||
}
|
||||
else
|
||||
{
|
||||
abd.lParam = ABS_AUTOHIDE;
|
||||
SHAppBarMessage(ABM_SETSTATE, &abd);
|
||||
}
|
||||
}
|
||||
|
@ -85,6 +85,8 @@ HRESULT ShellExecuteFromExplorer(
|
||||
int nShowCmd
|
||||
);
|
||||
|
||||
void ToggleTaskbarAutohide();
|
||||
|
||||
#pragma region "Weird stuff"
|
||||
INT64 STDMETHODCALLTYPE nimpl4_1(INT64 a1, DWORD* a2);
|
||||
INT64 STDMETHODCALLTYPE nimpl4_0(INT64 a1, DWORD* a2);
|
||||
|
Loading…
Reference in New Issue
Block a user