Reputation: 358
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
Upvotes: 1
Views: 208
Reputation: 5500
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
Upvotes: 1