Home > Net >  Any other mouse buttons pressed suppress MouseButtons.Left [C#]
Any other mouse buttons pressed suppress MouseButtons.Left [C#]

Time:05-26

Whenever you hold any other mouse button when the program is working it suppresses the work of it. Etc. Holding right mouse button stops clicking.

bool mousdown = MouseButtons == MouseButtons.Left;
                

                if (mousdown)
                {
                    mouse_event(LEFTUP, 0, 0, 0, 0);
                    WaitMilliSec(clickDelay);          // CLICKS
                    mouse_event(LEFTDOWN, 0, 0, 0, 0);
                }

I have tried doing stuff like:

if (MouseButtons == MouseButtons.Right)
{
return;
}

But honestly I don't know how to prevent it.

CodePudding user response:

private void button1_MouseDown(object sender, MouseEventArgs e)
{
    if(e.Button == MouseButtons.Right)
    {
        // do somthing
    }
}

CodePudding user response:

So instead of using MouseButtons == MouseButtons.Left Use (GetAsyncKeyState(Keys.LButton) < 0);

  • Related