Example #1
0
        int MouseEvents(int code, IntPtr wParam, IntPtr lParam)
        {
            if (code < 0)
            {
                return(Native.CallNextHookEx(_hook, code, wParam, lParam));
            }

            if (code == this.hcAction)
            {
                // Left button pressed somewhere
                if (wParam.ToInt32() == (uint)Native.Message.WM_LBUTTONUP)
                {
                    Native.MSLLHOOKSTRUCT ms = new Native.MSLLHOOKSTRUCT();
                    ms = (Native.MSLLHOOKSTRUCT)Marshal.PtrToStructure(
                        lParam,
                        typeof(Native.MSLLHOOKSTRUCT));

                    IntPtr win = Native.WindowFromPoint(ms.pt);

                    string title = GetWindowTextRaw(win);
                    if (LButtonUpClicked != null)
                    {
                        LButtonUpClicked(
                            this,
                            new SysMouseEventInfo {
                            WindowTitle = title
                        });
                    }
                }
            }
            return(Native.CallNextHookEx(_hook, code, wParam, lParam));
        }
        int MouseEvents(int code, IntPtr wParam, IntPtr lParam)
        {
            if (code < 0)
                return Native.CallNextHookEx(_hook, code, wParam, lParam);

            if (code == this.hcAction)
            {
                // Left button pressed somewhere
                if (wParam.ToInt32() == (uint)Native.Message.WM_LBUTTONDOWN)
                {
                    Native.MSLLHOOKSTRUCT ms = new Native.MSLLHOOKSTRUCT();
                    ms = (Native.MSLLHOOKSTRUCT)Marshal.PtrToStructure(
                        lParam,
                        typeof(Native.MSLLHOOKSTRUCT));

                    IntPtr win = Native.WindowFromPoint(ms.pt);

                    string title = GetWindowTextRaw(win);
                    if (LButtonDownClicked != null)
                    {
                        LButtonDownClicked(
                            this,
                            new SysMouseEventInfo { WindowTitle = title });
                    }
                }
            }
            return Native.CallNextHookEx(_hook, code, wParam, lParam);
        }