示例#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
         ));
 }
示例#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
         ));
 }
示例#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
         ));
 }
示例#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.WM_CHAR) || (message.Id == NativeConstants.WM_SYSCHAR))
            {
                // 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.WM_KEYDOWN) || (message.Id == NativeConstants.WM_SYSKEYDOWN))
                {
                    InputEventKeyboard e = new InputEventKeyboard(KeyboardEvent.Down,
                        (WinKeys)(int)(long)message.WParam,
                        (int)(long)message.LParam,
                        ModifierKeys
                        );
                    invokeKeyDown(e);
                }
                else if ((message.Id == NativeConstants.WM_KEYUP) || (message.Id == NativeConstants.WM_SYSKEYUP))
                {
                    InputEventKeyboard e = new InputEventKeyboard(KeyboardEvent.Up,
                        (WinKeys)(int)(long)message.WParam,
                        (int)(long)message.LParam,
                        ModifierKeys
                        );
                    invokeKeyUp(e);
                }
            }
        }
示例#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) == WP_NOPASSTHROUGH)
         return IntPtr.Zero;
     return base.WndProcHook(hWnd, msg, wParam, lParam);
 }
示例#6
0
        protected bool WndPrc(ref Message message)
        {
            try
            {
                switch (message.Id)
                {
                    case NativeConstants.WM_DEADCHAR:
                        {
                            break;
                        }
                    case NativeConstants.WM_KEYDOWN:
                    case NativeConstants.WM_KEYUP:
                    case NativeConstants.WM_CHAR:
                        {

                            WmKeyEvent(ref message);

                            break;
                        }
                    case NativeConstants.WM_UNICHAR:
                        break;
                    case NativeConstants.WM_SYSKEYDOWN:
                    case NativeConstants.WM_SYSKEYUP:
                    case NativeConstants.WM_SYSCHAR:
                        {
                            NativeMethods.TranslateMessage(ref message);
                            WmKeyEvent(ref message);
                            return WP_NOPASSTHROUGH;
                        }
                    case NativeConstants.WM_SYSCOMMAND:
                        {
                            break;
                        }
                    case NativeConstants.WM_MOUSEMOVE:
                        {
                            WmMouseMove(ref message);
                            break;
                        }
                    case NativeConstants.WM_LBUTTONDOWN:
                        {
                            WmMouseDown(ref message, WinMouseButtons.Left, 1);
                            break;
                        }
                    case NativeConstants.WM_RBUTTONDOWN:
                        {
                            WmMouseDown(ref message, WinMouseButtons.Right, 1);
                            break;
                        }
                    case NativeConstants.WM_MBUTTONDOWN:
                        {
                            WmMouseDown(ref message, WinMouseButtons.Middle, 1);
                            break;
                        }
                    case NativeConstants.WM_LBUTTONUP:
                        {
                            WmMouseUp(ref message, WinMouseButtons.Left, 1);
                            return WP_PASSTHROUGH;
                        }
                    case NativeConstants.WM_RBUTTONUP:
                        {
                            WmMouseUp(ref message, WinMouseButtons.Right, 1);
                            return WP_PASSTHROUGH;
                        }
                    case NativeConstants.WM_MBUTTONUP:
                        {
                            WmMouseUp(ref message, WinMouseButtons.Middle, 1);
                            return WP_PASSTHROUGH;
                        }
                    case NativeConstants.WM_LBUTTONDBLCLK:
                        {
                            WmMouseDown(ref message, WinMouseButtons.Left, 2);
                            return WP_PASSTHROUGH;
                        }
                    case NativeConstants.WM_RBUTTONDBLCLK:
                        {
                            WmMouseDown(ref message, WinMouseButtons.Right, 2);
                            return WP_PASSTHROUGH;
                        }
                    case NativeConstants.WM_MBUTTONDBLCLK:
                        {
                            WmMouseDown(ref message, WinMouseButtons.Middle, 2);
                            return WP_PASSTHROUGH;
                        }
                    case NativeConstants.WM_MOUSEWHEEL:
                        {
                            WmMouseWheel(ref message);
                            return WP_PASSTHROUGH;
                        }
                    case NativeConstants.WM_XBUTTONDOWN:
                        {
                            WmMouseDown(ref message, GetXButton(Message.HighWord(message.WParam)), 1);
                            return WP_PASSTHROUGH;
                        }
                    case NativeConstants.WM_XBUTTONUP:
                        {
                            WmMouseUp(ref message, GetXButton(Message.HighWord(message.WParam)), 1);
                            return WP_PASSTHROUGH;
                        }
                    case NativeConstants.WM_XBUTTONDBLCLK:
                        {
                            WmMouseDown(ref message, GetXButton(Message.HighWord(message.WParam)), 2);
                            return WP_PASSTHROUGH;
                        }
                }
            }
            catch
            {
                //TODO: log...crash...what?
            }

            return WP_PASSTHROUGH;
        }
示例#7
0
 internal static extern bool TranslateMessage(ref Message m);
示例#8
0
 internal static extern bool GetMessage(out Message lpMsg, IntPtr hWnd, uint wMsgFilterMin, uint wMsgFilterMax);