Ejemplo n.º 1
0
        private static IntPtr MouseProc(int nCode, IntPtr wParam, IntPtr lParam)
        {
            if (nCode >= 0)
            {
                _mouseParam = (Win32Api.MOUSEHOOKSTRUCT)Marshal.PtrToStructure(lParam, typeof(Win32Api.MOUSEHOOKSTRUCT));
                var mouseMessage = (Win32Api.MouseMessages)wParam;

                if (UseGlobal)
                {
                    if (mouseMessage == Win32Api.MouseMessages.WM_LBUTTONDOWN || mouseMessage == Win32Api.MouseMessages.WM_LBUTTONUP)
                    {
                        MouseClickEvent?.Invoke(_mouseParam.pt, mouseMessage);

                        if (mouseMessage == Win32Api.MouseMessages.WM_LBUTTONDOWN && IsHookingArea())
                        {
                            return((IntPtr)1);
                        }
                    }
                }
            }

            return(Win32Api.CallNextHookEx(_mouseId, nCode, wParam, lParam));
        }
Ejemplo n.º 2
0
        private static IntPtr MouseProc(int nCode, IntPtr wParam, IntPtr lParam)
        {
            if (nCode >= 0)
            {
                _mouseParam = (Win32Api.MOUSEHOOKSTRUCT)Marshal.PtrToStructure(lParam, typeof(Win32Api.MOUSEHOOKSTRUCT));
                var mouseMessage = (Win32Api.MouseMessages)wParam;

                if (UseGlobal)
                {
                    if (mouseMessage == Win32Api.MouseMessages.WM_LBUTTONDOWN || mouseMessage == Win32Api.MouseMessages.WM_LBUTTONUP)
                    {
                        var onMouseClickEvent = MouseClickEvent;
                        if (onMouseClickEvent != null)
                        {
                            onMouseClickEvent(_mouseParam.pt, mouseMessage);
                        }

                        if (mouseMessage == Win32Api.MouseMessages.WM_LBUTTONDOWN && IsHookingArea())
                        {
                            return (IntPtr)1;
                        }
                    }
                }
            }

            return Win32Api.CallNextHookEx(_mouseId, nCode, wParam, lParam);
        }