gmamaladze / globalmousekeyhook

This library allows you to tap keyboard and mouse, detect and record their activity even when an application is inactive and runs in background.
MIT License
1.05k stars 257 forks source link

How to disable the trigger of the right mouse button #136

Open yisqiu opened 3 years ago

yisqiu commented 3 years ago

I hook the right mouse button but I don't want the right mouse button click to show the right-click menu, that is, I want to prohibit right-click messages from being sent to other programs. How should it be realized?

    private void Hook_MouseDownExt(object sender, MouseEventExtArgs e)
    {
        if (e.Button == MouseButtons.Right)
        {
            SendKeys.SendWait("^c");

        }
    }
PromoFaux commented 3 years ago

The demo code shows you how to disable the key outside of what you're handling. Use e.Handled = true once you've done your intercept code I guess.

One thing I noticed is that I had to add the call to Hook_MouseDownExt to both MouseDownExt and MouseUpExt for it to function