I'm trying to write a Teamspeak 3 plugin that suppresses mouse 4 and 5 for other programs using SetWindowsHookEx
with WH_MOUSE_LL
. Knowing that Mumble pretty much does this, I downloaded the source code and rummaged through it. So far I've managed to get the callback to work globally with the xbuttons(mouse 4 and 5), but I can't seem to get it to suppress it for other programs despite returning 1. Google Chrome for example still insists on going back when I press mouse 4, which Mumble has no issues preventing using the same method as I am.
Here's what I've got so far:
GetModuleHandleEx(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS | GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT, (wchar_t *) &MouseCallback, &hSelf);
hMouseHook = SetWindowsHookEx(WH_MOUSE_LL, MouseCallback, hSelf, 0);
And the callback:
if(wParam == WM_XBUTTONDOWN)
{
MessageBox(NULL, L"xbutton", L"xbutton", MB_OK); // Works
return 1; // Doesn't seem to do anything different
}
else
{
return CallNextHookEx(hMouseHook, nCode, wParam, lParam);
}
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…