1

Our client has specific mouses - they have 2 scrolls. On the 'mainScroll_click' he wants us to trigger event A and on the 'scroll2_click' event B.

Is it possible using c#? Or should I seek help in the mouse drivers?

For middle button i have always used:

if (e.MiddleButton) { MessageBox.Show("Middle!"); }

but i can't find any information about MiddleButton2

Pieczarr
  • 348
  • 4
  • 13
  • I would check into the driver documentation for the 2-wheeled product. As this is quite bespoke and out of the ordinary they may even have an SDK you would be able to incorporate with your program. – Harvey May 19 '16 at 11:01
  • Usually extended functions are soft-mapped to keys, eg PgUp/PgDwn or arrows. Or XButtons. I would either push for physical access to said device or create some test app to log events. – PTwr May 19 '16 at 11:06
  • 1
    XButton1 and XButton2 corresponds to the ThumbButtons (those on the left side of a normal mouse), not to the second wheel – Pieczarr May 19 '16 at 11:09
  • Handle `MouseClick` event and check what the value of `e.Button` is when you click using second wheel. – Reza Aghaei May 19 '16 at 11:10
  • 1
    Neither the winapi nor Winforms has any support for more than one mousewheel or second middle button. Such mice typically require a custom driver and is written to recognize popular programs like browsers and Office and manipulate them with UI Automation. But yeah, not yours of course. If the vendor's software doesn't have a way to add support for additional programs then you'll have a difficult support call that nobody is likely to answer. – Hans Passant May 19 '16 at 12:21
  • Games often use DirectInput or raw mouse input to handle the additional buttons, where the WinAPI can only handle the two extra buttons on the side ('back' and 'next'). WinForms builds directly on the WinAPI, so again only 2 extra buttons. – MicroVirus May 19 '16 at 13:05

1 Answers1

1

There is no middle2 as the default mouse is assumed to be 2 or 3 buttons.

however mice with additional special buttons for things like back and forward have been around almost as long as wheels,

if you look at MouseButtons Enumeration you will see it has provision for 2 special buttons XButton1, XButton2, i would hope that the manufactures are mapping to one of them but that depends on the manufacturer of the mice

to get the greater detail you need to move to the mouse events rather than just the basic click, such as MouseCLick, MouseUp, MouseDown

    private void panel1_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e) 
    {
        // Update the mouse path with the mouse information
        Point mouseDownLocation = new Point(e.X, e.Y);

        string eventString = null;
        switch (e.Button) {
            case MouseButtons.Left:
                eventString = "L";
                break;
            case MouseButtons.Right:
                eventString = "R";
                break;
            case MouseButtons.Middle:
                eventString = "M";
                break;
            case MouseButtons.XButton1:
                eventString = "X1";
                break;
            case MouseButtons.XButton2:
                eventString = "X2";
                break;
            case MouseButtons.None:
            default:
                break;
        }

if they haven't been nice enough to conform to the standard mice interfaces you may need to process them at a much lower level in which case nitrogenycs reply to Mouse Wheel Event (C#) shows how to intercept and process the raw event

Community
  • 1
  • 1
MikeT
  • 5,398
  • 3
  • 27
  • 43
  • Mouse arrived from client, it appeared that it has no thumb buttons and it triggered X2 button with 2nd wheel click. – Pieczarr May 20 '16 at 11:11