private IntPtr HookCallBack(int nCode, IntPtr wParam, IntPtr lParam) { StructMSLLHOOKSRTUCT hookStruct; if (nCode < 0) { return(DllUser32.CallNextHookEx(_hookId, nCode, wParam, lParam)); } hookStruct = (StructMSLLHOOKSRTUCT)Marshal.PtrToStructure(lParam, typeof(StructMSLLHOOKSRTUCT)); MouseAction(null, new RawMouseEventArgs { MouseMessage = (EnumWinMsgs)wParam, Point = hookStruct.pt, MouseInfo = hookStruct.mouseData }); return(DllUser32.CallNextHookEx(_hookId, nCode, wParam, lParam)); }
private IntPtr LowLevelKeyboardProc(int nCode, UIntPtr wParam, IntPtr lParam) { if (nCode >= 0) { if (wParam.ToUInt32() == (int)Enums.EnumKeyEvent.WM_KEYDOWN || wParam.ToUInt32() == (int)Enums.EnumKeyEvent.WM_KEYUP || wParam.ToUInt32() == (int)Enums.EnumKeyEvent.WM_SYSKEYDOWN || wParam.ToUInt32() == (int)Enums.EnumKeyEvent.WM_SYSKEYUP) { string chars = InterceptKeys.VkCodeToString((uint)Marshal.ReadInt32(lParam), wParam.ToUInt32() == (int)Enums.EnumKeyEvent.WM_KEYDOWN || wParam.ToUInt32() == (int)Enums.EnumKeyEvent.WM_SYSKEYDOWN); _hookedKeyboardCallbackAsync.BeginInvoke((Enums.EnumKeyEvent)wParam.ToUInt32(), Marshal.ReadInt32(lParam), chars, null, null); } } return(DllUser32.CallNextHookEx(_hookId, nCode, wParam, lParam)); }