Beispiel #1
0
        public int MouseHookInvoked(object sender, HookEventArgs e)
        {
            uint wParam = (uint)((int)e.wParam);
            EventHandler <MouseEventArgs> mouseMove = null;
            MouseEventArgs args = null;

            switch (wParam)
            {
            case 0x200:
                mouseMove = this.MouseMove;
                args      = this.DecodeMouseMove(e.lParam);
                break;

            case 0x201:
                mouseMove = this.MouseDown;
                args      = this.DecodeLowLevelMouse(e.lParam);
                break;

            case 0x202:
                mouseMove = this.MouseUp;
                args      = this.DecodeLowLevelMouse(e.lParam);
                break;
            }
            if ((mouseMove != null) && (args != null))
            {
                mouseMove(this, args);
            }
            return(0);
        }
Beispiel #2
0
        public int MouseHookInvoked(object sender, HookEventArgs e)
        {
            uint wParam = (uint) ((int) e.wParam);
            EventHandler<MouseEventArgs> mouseMove = null;
            MouseEventArgs args = null;
            switch (wParam)
            {
                case 0x200:
                    mouseMove = this.MouseMove;
                    args = this.DecodeMouseMove(e.lParam);
                    break;

                case 0x201:
                    mouseMove = this.MouseDown;
                    args = this.DecodeLowLevelMouse(e.lParam);
                    break;

                case 0x202:
                    mouseMove = this.MouseUp;
                    args = this.DecodeLowLevelMouse(e.lParam);
                    break;
            }
            if ((mouseMove != null) && (args != null))
            {
                mouseMove(this, args);
            }
            return 0;
        }
Beispiel #3
0
 protected int CoreHookProc(int nCode, IntPtr wParam, IntPtr lParam)
 {
     HookEventArgs e = new HookEventArgs();
     e.HookCode = nCode;
     e.wParam = wParam;
     e.lParam = lParam;
     if (this.hookType == HookType.WH_CALLWNDPROC)
     {
         e.cwstruct = (CallWndStruct) Marshal.PtrToStructure(lParam, typeof(CallWndStruct));
     }
     else if (this.hookType == HookType.WH_GETMESSAGE)
     {
         e.message = (Message) Marshal.PtrToStructure(lParam, typeof(Message));
     }
     if (nCode >= 0)
     {
         int num = this.OnHookInvoked(e);
         if (num != 0)
         {
             return num;
         }
     }
     if (this.hookType == HookType.WH_CALLWNDPROC)
     {
         return Win32.CallNextHookEx(this.hHook, nCode, wParam, ref e.cwstruct);
     }
     return Win32.CallNextHookEx(this.hHook, nCode, wParam, ref e.message);
 }
        protected int OnHookInvoked(HookEventArgs e)
        {
            int num = 0;

            if (this.HookInvoked != null)
            {
                num = this.HookInvoked(this, e);
            }
            return(num);
        }
Beispiel #5
0
        protected int OnHookInvoked(HookEventArgs e)
        {
            int result = 0;

            if (HookInvoked != null)
            {
                result = HookInvoked(this, e);
            }
            return(result);
        }
Beispiel #6
0
        public int GestureHookInvoked(object sender, HookEventArgs e)
        {
            switch (e.message.msg)
            {
            case 0x119:
                this.DecodeGesture(ref e.message);
                break;

            case 0x11a:
                this.ConfigureGesturesForSubmission();
                break;
            }
            return(0);
        }
Beispiel #7
0
        // Not sure why this was here.  Doesn't seem to make any difference
        // and really bothers the Microsoft Store checks.
        //[PermissionSet(SecurityAction.Demand, Name = "FullTrust")]
#endif
        protected int CoreHookProc(int nCode, IntPtr wParam, IntPtr lParam)
        {
            //Message msg = (Message)Marshal.PtrToStructure(lParam, typeof(Message));
            //CallWndStruct cwstruct = (CallWndStruct)Marshal.PtrToStructure(lParam, typeof(CallWndStruct));

            //Console.WriteLine("CoreHookProc: m.msg=0x" + m.msg.ToString("X"));
            //Console.WriteLine("CoreHookProc: nCode=" + nCode.ToString() + "wParam=0x" + wParam.ToString("X"));

            HookEventArgs e = new HookEventArgs();

            e.HookCode = nCode;
            e.wParam   = wParam;
            e.lParam   = lParam;
            //e.message = m;
            if (hookType == HookType.WH_CALLWNDPROC)
            {
                e.cwstruct = (CallWndStruct)Marshal.PtrToStructure(lParam, typeof(CallWndStruct));
            }
            else
            if (hookType == HookType.WH_GETMESSAGE)
            {
                e.message = (Message)Marshal.PtrToStructure(lParam, typeof(Message));
            }
            else
            {
                Debug.Assert(false, "Unexpected Hook Type!");
            }

            if (nCode >= 0)  //&& wParam != IntPtr.Zero)
            {
                int result = OnHookInvoked(e);
                if (result != 0)
                {
                    return(result);
                }
            }

            //TODO: Refactor to avoid duplicate code.
            if (hookType == HookType.WH_CALLWNDPROC)
            {
                return(Win32.CallNextHookEx(hHook, nCode, wParam, ref e.cwstruct)); //windows 8
            }
            return(Win32.CallNextHookEx(hHook, nCode, wParam, ref e.message));      //windows 7
        }
Beispiel #8
0
 public int TouchHookInvoked(object sender, HookEventArgs e)
 {
     if (base.hookType == HookType.WH_CALLWNDPROC)
     {
         if (e.cwstruct.message == 0x240)
         {
             this.DecodeTouch(e.cwstruct.wparam, e.cwstruct.lparam);
         }
     }
     else if (base.hookType == HookType.WH_GETMESSAGE)
     {
         switch (e.message.msg)
         {
         case 0x200:
         case 0x201:
         case 0x202:
         case 0x203:
         case 0x2a3:
         {
             long num  = Win32.GetMessageExtraInfo().ToInt64();
             bool flag = false;
             if ((((ulong)num) & 0xff515700L) == 0xff515700L)
             {
                 flag = true;
             }
             else if ((e.message.msg == 0x200) && FoundSimilarTouchCapture(e.message.time, e.message.lparam))
             {
                 flag = true;
             }
             if (flag)
             {
                 e.message.msg = 0;
             }
             else
             {
                 capturedTouches.Clear();
             }
             break;
         }
         }
     }
     return(0);
 }
Beispiel #9
0
        public int GestureHookInvoked(object sender, HookEventArgs e)
        {
            switch (e.message.msg)
            {
            case Win32.WM_GESTURENOTIFY:
            {
                ConfigureGesturesForSubmission();
            }
            break;

            case Win32.WM_GESTURE:
            {
                DecodeGesture(ref e.message);
            }
            break;

            default:
                break;
            }
            return(0);
        }
        public event EventHandler <MouseEventArgs> MouseMove;   // touch move event handler

        public int MouseHookInvoked(object sender, HookEventArgs e)
        {
            uint message = (uint)e.wParam;
            EventHandler <MouseEventArgs> handler = null;
            MouseEventArgs args = null;

            switch (message)
            {
            case Win32.WM_MOUSEMOVE:
            {
                handler = MouseMove;
                args    = DecodeMouseMove(e.lParam);
            }
            break;

            case Win32.WM_LBUTTONDOWN:
            {
                handler = MouseDown;
                args    = DecodeLowLevelMouse(e.lParam);
            }
            break;

            case Win32.WM_LBUTTONUP:
            {
                handler = MouseUp;
                args    = DecodeLowLevelMouse(e.lParam);
            }
            break;

            default:
                break;
            }

            if (handler != null && args != null)
            {
                handler(this, args);
            }
            return(0);
        }
Beispiel #11
0
 public int TouchHookInvoked(object sender, HookEventArgs e)
 {
     if (base.hookType == HookType.WH_CALLWNDPROC)
     {
         if (e.cwstruct.message == 0x240)
         {
             this.DecodeTouch(e.cwstruct.wparam, e.cwstruct.lparam);
         }
     }
     else if (base.hookType == HookType.WH_GETMESSAGE)
     {
         switch (e.message.msg)
         {
             case 0x200:
             case 0x201:
             case 0x202:
             case 0x203:
             case 0x2a3:
             {
                 long num = Win32.GetMessageExtraInfo().ToInt64();
                 bool flag = false;
                 if ((((ulong) num) & 0xff515700L) == 0xff515700L)
                 {
                     flag = true;
                 }
                 else if ((e.message.msg == 0x200) && FoundSimilarTouchCapture(e.message.time, e.message.lparam))
                 {
                     flag = true;
                 }
                 if (flag)
                 {
                     e.message.msg = 0;
                 }
                 else
                 {
                     capturedTouches.Clear();
                 }
                 break;
             }
         }
     }
     return 0;
 }
Beispiel #12
0
 protected int OnHookInvoked(HookEventArgs e)
 {
     int num = 0;
     if (this.HookInvoked != null)
     {
         num = this.HookInvoked(this, e);
     }
     return num;
 }
Beispiel #13
0
        public int GestureHookInvoked(object sender, HookEventArgs e)
        {
            switch (e.message.msg)
            {
                case 0x119:
                    this.DecodeGesture(ref e.message);
                    break;

                case 0x11a:
                    this.ConfigureGesturesForSubmission();
                    break;
            }
            return 0;
        }
        public int TouchHookInvoked(object sender, HookEventArgs e)
        {
            if (hookType == HookType.WH_CALLWNDPROC)
            {
                //Console.WriteLine("e.cwstruct.message=0x" + e.cwstruct.message.ToString("X"));

                //windows 8 style
                switch (e.cwstruct.message)
                {
                case Win32.WM_TOUCH:
                {
                    //Console.WriteLine("Touch recieved");
                    DecodeTouch(e.cwstruct.wparam, e.cwstruct.lparam);
                }
                break;

                //case Win32.WM_SETCURSOR:
                //    // Nullify touch-generated mouse messages so they don't get passed down the chain.
                //    e.cwstruct.message = Win32.WM_NULL;
                //    break;
                default:
                    break;
                }
            }
            else
            if (hookType == HookType.WH_GETMESSAGE)
            {
                //windows 7 style
                //Console.WriteLine("e.message.msg=0x" + e.message.msg.ToString("X") );
                switch (e.message.msg)
                {
                case Win32.WM_TOUCH:
                {
                    //Console.WriteLine("Touch recieved");
                    //DecodeTouch(e.message.wparam, e.message.lparam);
                }
                break;

                case Win32.WM_MOUSEMOVE:
                case Win32.WM_LBUTTONDOWN:
                case Win32.WM_LBUTTONDBLCLK:
                case Win32.WM_LBUTTONUP:
                case Win32.WM_MOUSELEAVE:
                    //case Win32.WM_SETCURSOR:
                {
                    IntPtr extraInfoPtr = Win32.GetMessageExtraInfo();
                    long   extraInfo    = extraInfoPtr.ToInt64();

                    bool generatedFromTouch = false;

                    // Determine whether these mouse events were generated by a touch.
                    if ((extraInfo & Win32.MOUSEEVENTF_FROMTOUCH) == Win32.MOUSEEVENTF_FROMTOUCH)
                    {
                        generatedFromTouch = true;
                    }
                    else if (e.message.msg == Win32.WM_MOUSEMOVE)
                    {
                        if (FoundSimilarTouchCapture(e.message.time, e.message.lparam))
                        {
                            generatedFromTouch = true;
                        }
                        else
                        {
                            // JW - Useful debug lines to find out why mousemoves were accepted.
                            //int xPos = Win32.GET_X_LPARAM(e.message.lparam);
                            //int yPos = Win32.GET_Y_LPARAM(e.message.lparam);
                            //Console.Write("MouseMove: " + xPos + ":" + yPos + "\n");
                            //OutputCapturedTouches();
                        }
                    }

                    if (generatedFromTouch)
                    {
                        // Nullify touch-generated mouse messages so they don't get passed down the chain.
                        e.message.msg = Win32.WM_NULL;
                    }
                    else
                    {
                        // Legitimate mouse events have begun, so our previous touch captures
                        // are no longer valid for comparison.
                        capturedTouches.Clear();
                    }
                }
                break;

                default:
                    break;
                }
            }

            return(0);
        }