There are several available events raised by the MouseKeyboardActivityMonitor
. For a mouse down event you can choose to listen to either MouseDown
or MouseDownExt
. The latter supplies you with some extra options in the MouseEventExtArgs
parameter, such as a Handled
property. If you set this to true, the event will not propagate further.
When it comes to MouseDoubleClick
event, there is no extended event available. I would therefore suggest that you implement the double click listener yourself by utilizing the MouseDownExt
listener and counting the number of clicks that has occurred.
public void Initialize() {
// Initialize your listener and set up event listeners
MyMouseHookListener = new MouseHookListener(new AppHooker()) {Enabled = true};
MyMouseHookListener.MouseDownExt += MyMouseHookListenerOnMouseDownExt;
// UNDONE Delete when testing is done; included to show that the listener is never called
MyMouseHookListener.MouseDoubleClick += MyMouseHookListenerOnMouseDoubleClick;
}
private static void MyMouseHookListenerOnMouseDoubleClick(object sender, MouseEventArgs mouseEventArgs)
{
// NOTE: This listener should never be called
Debug.Print("Mouse double-click!");
}
private static void MyMouseHookListenerOnMouseDownExt(object sender, MouseEventExtArgs mouseEventExtArgs)
{
Debug.Print("Mouse down. Number of clicks: {0}", mouseEventExtArgs.Clicks);
if (mouseEventExtArgs.Clicks == 2)
{
// TODO Insert your double-click code here
mouseEventExtArgs.Handled = true;
}
}
To be exhaustive, you should perhaps also test whether it is the left or right button that has been clicked, which you can to by checking the MouseEventExtArgs.Button
property. A right-double-click will now be counted as a double-click, however, this is as far as I know similar to the original MouseDoubleClick
event.