Exemple #1
0
        /// <summary>
        /// 마우스 프로시저 처리하기
        /// </summary>
        /// <param name="code">코드</param>
        /// <param name="wordParameter">WORD 매개 변수</param>
        /// <param name="longParameter">LONG 매개 변수</param>
        /// <returns>처리 결과</returns>
        private static IntPtr MouseProc(int code, IntPtr wordParameter, IntPtr longParameter)
        {
            if (code >= 0)
            {
                _mouseHookStructure = (MOUSEHOOKSTRUCT)Marshal.PtrToStructure
                                      (
                    longParameter,
                    typeof(MOUSEHOOKSTRUCT)
                                      );

                MouseMessage mouseMessage = (MouseMessage)wordParameter;

                if (UseGlobal)
                {
                    if (mouseMessage == MouseMessage.WM_LBUTTONDOWN || mouseMessage == MouseMessage.WM_LBUTTONUP)
                    {
                        MouseClick?.Invoke(_mouseHookStructure.Location, mouseMessage);

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

            return(WIN32Helper.CallNextHookEx(_mouseHookHandle, code, wordParameter, longParameter));
        }
Exemple #2
0
        /// <summary>
        /// 키보드 프로시저 처리하기
        /// </summary>
        /// <param name="code">코드</param>
        /// <param name="wordParameter">WORD 매개 변수</param>
        /// <param name="longParameter">LONG 매개 변수</param>
        /// <returns>처리 결과</returns>
        private static IntPtr KeyboardProc(int code, IntPtr wordParameter, IntPtr longParameter)
        {
            if (code == WIN32Helper.HC_ACTION)
            {
                uint wordParameterValue = (uint)wordParameter;
                long longParamererValue = (long)longParameter;

                if (wordParameterValue == 256)
                {
                    KEYBOARDHOOKSTRUCT keyboardHookStructure = (KEYBOARDHOOKSTRUCT)Marshal.PtrToStructure
                                                               (
                        longParameter,
                        typeof(KEYBOARDHOOKSTRUCT)
                                                               );

                    KeyClick?.Invoke(keyboardHookStructure.VirtualKeyCode);
                }

                if ((wordParameterValue == 229 && longParamererValue == -2147483647) || (wordParameterValue == 229 && longParamererValue == -2147483648))
                {
                    if (IsHookingArea())
                    {
                        return((IntPtr)1);
                    }
                }
            }

            return(WIN32Helper.CallNextHookEx(_keyboardHookHandle, code, wordParameter, longParameter));
        }