Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
254 views
in Technique[技术] by (71.8m points)

c++ - Returning 1 in LowLevelMouseProc doesn't suppress the key in other programs

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...