Beispiel #1
0
 /// <summary>
 /// Reads the supplied message and executes any Mouse Wheel events required.
 /// </summary>
 /// <param name="message">The Message to parse</param>
 private void WmMouseWheel(ref Message message)
 {
     InvokeMouseWheel(new InputEventMouse(MouseEvent.WheelScroll,
         TranslateWParamIntoMouseButtons(Message.SignedLowWord(message.WParam)),
         Message.SignedHighWord(message.WParam),
         Message.SignedLowWord(message.LParam),
         Message.SignedHighWord(message.LParam),
         (int)(long)message.WParam,
         ModifierKeys
         ));
 }
Beispiel #2
0
 /// <summary>
 /// Reads the supplied message and executes any Mouse Move events required.
 /// </summary>
 /// <param name="message">The Message to parse</param>
 private void WmMouseMove(ref Message message)
 {
     InvokeMouseMove(new InputEventMouse(MouseEvent.Move,
         TranslateWParamIntoMouseButtons(Message.SignedLowWord(message.WParam)),
         0,
         message.Point.X,
         message.Point.Y,
         (int)(long)message.WParam,
         ModifierKeys
         ));
 }
Beispiel #3
0
 /// <summary>
 /// Reads the supplied message and executes any Mouse Up events required.
 /// </summary>
 /// <param name="message">The Message to parse</param>
 /// <param name="button">The Mouse Button the Message is for</param>
 /// <param name="clicks">The number of clicks for the Message</param>
 private void WmMouseUp(ref Message message, WinMouseButtons button, int clicks)
 {
     // HandleMouseBindings();
     InvokeMouseUp(new InputEventMouse(MouseEvent.Up,
         button,
         clicks,
         Message.SignedLowWord(message.LParam),
         Message.SignedHighWord(message.LParam),
         (int)(long)message.WParam,
         ModifierKeys
         ));
 }
Beispiel #4
0
 /// <summary>
 /// Reads the supplied message and executes any Keyboard events required.
 /// </summary>
 /// <param name="message">The Message to parse</param>
 /// <returns>A Boolean value indicating wether the Key events were handled or not</returns>
 private void WmKeyEvent(ref Message message)
 {
     // HandleKeyBindings();
     // KeyPressEventArgs keyPressEventArgs = null;
     if ((message.Id == NativeConstants.WmChar) || (message.Id == NativeConstants.WmSyschar)) {
         // Is this extra information necessary?
         // wm_(sys)char: http://msdn.microsoft.com/en-us/library/ms646276(VS.85).aspx
         InputEventKeyboard e = new InputEventKeyboard(KeyboardEvent.Press,
             (WinKeys)(int)(long)message.WParam,
             (int)(long)message.LParam,
             ModifierKeys
             );
         IntPtr zero = (IntPtr)0;
         InvokeChar(e);
     }
     else {
         // wm_(sys)keydown: http://msdn.microsoft.com/en-us/library/ms912654.aspx
         // wm_(sys)keyup: http://msdn.microsoft.com/en-us/library/ms646281(VS.85).aspx
         if ((message.Id == NativeConstants.WmKeydown) || (message.Id == NativeConstants.WmSyskeydown)) {
             InputEventKeyboard e = new InputEventKeyboard(KeyboardEvent.Down,
                 (WinKeys)(int)(long)message.WParam,
                 (int)(long)message.LParam,
                 ModifierKeys
                 );
             InvokeKeyDown(e);
         }
         else if ((message.Id == NativeConstants.WmKeyup) || (message.Id == NativeConstants.WmSyskeyup)) {
             InputEventKeyboard e = new InputEventKeyboard(KeyboardEvent.Up,
                 (WinKeys)(int)(long)message.WParam,
                 (int)(long)message.LParam,
                 ModifierKeys
                 );
             InvokeKeyUp(e);
         }
     }
 }
Beispiel #5
0
 protected override IntPtr WndProcHook(IntPtr hWnd, uint msg, IntPtr wParam, IntPtr lParam)
 {
     Message message = new Message(msg, wParam, lParam);
     if (WndPrc(ref message) == c_WpNopassthrough)
         return IntPtr.Zero;
     return base.WndProcHook(hWnd, msg, wParam, lParam);
 }
Beispiel #6
0
 protected bool WndPrc(ref Message message)
 {
     try {
         switch (message.Id) {
             case NativeConstants.WmDeadchar: {
                 break;
             }
             case NativeConstants.WmKeydown:
             case NativeConstants.WmKeyup:
             case NativeConstants.WmChar: {
                 WmKeyEvent(ref message);
                 break;
             }
             case NativeConstants.WmUnichar:
                 break;
             case NativeConstants.WmSyskeydown:
             case NativeConstants.WmSyskeyup:
             case NativeConstants.WmSyschar: {
                 NativeMethods.TranslateMessage(ref message);
                 WmKeyEvent(ref message);
                 return c_WpNopassthrough;
             }
             case NativeConstants.WmSyscommand: {
                 break;
             }
             case NativeConstants.WmMousemove: {
                 WmMouseMove(ref message);
                 break;
             }
             case NativeConstants.WmLbuttondown: {
                 WmMouseDown(ref message, WinMouseButtons.Left, 1);
                 break;
             }
             case NativeConstants.WmRbuttondown: {
                 WmMouseDown(ref message, WinMouseButtons.Right, 1);
                 break;
             }
             case NativeConstants.WmMbuttondown: {
                 WmMouseDown(ref message, WinMouseButtons.Middle, 1);
                 break;
             }
             case NativeConstants.WmLbuttonup: {
                 WmMouseUp(ref message, WinMouseButtons.Left, 1);
                 return c_WpPassthrough;
             }
             case NativeConstants.WmRbuttonup: {
                 WmMouseUp(ref message, WinMouseButtons.Right, 1);
                 return c_WpPassthrough;
             }
             case NativeConstants.WmMbuttonup: {
                 WmMouseUp(ref message, WinMouseButtons.Middle, 1);
                 return c_WpPassthrough;
             }
             case NativeConstants.WmLbuttondblclk: {
                 WmMouseDown(ref message, WinMouseButtons.Left, 2);
                 return c_WpPassthrough;
             }
             case NativeConstants.WmRbuttondblclk: {
                 WmMouseDown(ref message, WinMouseButtons.Right, 2);
                 return c_WpPassthrough;
             }
             case NativeConstants.WmMbuttondblclk: {
                 WmMouseDown(ref message, WinMouseButtons.Middle, 2);
                 return c_WpPassthrough;
             }
             case NativeConstants.WmMousewheel: {
                 WmMouseWheel(ref message);
                 return c_WpPassthrough;
             }
             case NativeConstants.WmXbuttondown: {
                 WmMouseDown(ref message, GetXButton(Message.HighWord(message.WParam)), 1);
                 return c_WpPassthrough;
             }
             case NativeConstants.WmXbuttonup: {
                 WmMouseUp(ref message, GetXButton(Message.HighWord(message.WParam)), 1);
                 return c_WpPassthrough;
             }
             case NativeConstants.WmXbuttondblclk: {
                 WmMouseDown(ref message, GetXButton(Message.HighWord(message.WParam)), 2);
                 return c_WpPassthrough;
             }
         }
     }
     catch {
         //TODO: log...crash...what?
     }
     return c_WpPassthrough;
 }
Beispiel #7
0
 internal static extern bool GetMessage(out Message lpMsg, IntPtr hWnd, uint wMsgFilterMin, uint wMsgFilterMax);
Beispiel #8
0
 internal static extern bool TranslateMessage(ref Message m);