Reputation: 229441
Is there any way to disable regular windows mouse clicks using the win API? I can disable clicks anywhere besides a particular point by doing ClipCursor
, but the clicks still register.
Alternatively I also want to disable mouse clicks conditionally... for example, I want to make it impossible to close a window of an application I don't control, so I want clicks sent to the 'X' of that window to not go through.
Upvotes: 0
Views: 2785
Reputation: 2538
You can, and it's very dangerous. Here's how, in c++
LRESULT __stdcall LowLevelMouseProc(int nCode, WPARAM wParam, LPARAM lParam)
{
if ((nCode < 0) || false)
{
result = CallNextHookEx(myLowLevelMouseHookHandle, nCode, wParam, lParam);
}
return result;
}
Change the false
in the example above to re-enable keyboard to work.
BTW this technique also works similarly with keyboard input, even Ctrl+Alt+Del wont work.
If you want to allow the mouse to move, but block clicks only, add some if ((wParam == WM_MOUSEMOVE) || (wParam == WM_NCMOUSEMOVE))
code.
More info at http://msdn.microsoft.com/en-us/library/ms644986(VS.85).aspx
Upvotes: 3