michel-pi/LowLevelInput.Net

Filtering LButton

Lockem90 opened this issue · 1 comments

I've been messing around with mouse filtering today and I've found that it works perfectly for RButton, but does not seem to block LButton properly.

        WindowsHookFilter.Filter += LbuttonHandler;
        WindowsHookFilter.Filter += RbuttonHandler;

        private static bool LbuttonHandler(VirtualKeyCode key, KeyState state)
        {
            if (!Engine.ReadyToRun)
                return false;

            return key == VirtualKeyCode.Lbutton;
        }

        private static bool RbuttonHandler(VirtualKeyCode key, KeyState state)
        {
            if (!Engine.ReadyToRun)
                return false;

            return key == VirtualKeyCode.Rbutton;
        }

This code seems to work for RButton, but not LButton.

you should only attach one event handler to the filter.
in your example it will always use the return value from the last called event handler.

use a switch statement or hold a list of keys to block.

i will change this event handler to a callback function in the next build.