public IntPtr HandleMouse(int nCode, IntPtr wParam, IntPtr lParam) { if (nCode >= 0 && MouseMessages.WM_LBUTTONDOWN == (MouseMessages)wParam) { c.Send(new byte[2] { 1, 0 }, 2, Constants.BROADCAST, Constants.PORT); } if (nCode >= 0 && MouseMessages.WM_LBUTTONUP == (MouseMessages)wParam) { c.Send(new byte[2] { 0, 0 }, 2, Constants.BROADCAST, Constants.PORT); } if (nCode >= 0 && MouseMessages.WM_RBUTTONDOWN == (MouseMessages)wParam) { c.Send(new byte[2] { 0, 1 }, 2, Constants.BROADCAST, Constants.PORT); } if (nCode >= 0 && MouseMessages.WM_RBUTTONUP == (MouseMessages)wParam) { c.Send(new byte[2] { 0, 0 }, 2, Constants.BROADCAST, Constants.PORT); } return(DLLImport.CallNextHookEx(hHook, nCode, wParam, lParam)); }
private IntPtr KeyboardHookDelegate(Int32 Code, IntPtr wParam, IntPtr lParam) { if (Code < 0) { return(DLLImport.CallNextHookEx( keyBoardHandle, Code, wParam, lParam)); } Console.WriteLine($"Code: {Code}, WP: {wParam}, LP: {lParam}"); KeyBoardKeyPressed?.Invoke(this, new KBArgs { Code = Code, WParam = wParam, LParam = lParam }); return(DLLImport.CallNextHookEx(keyBoardHandle, Code, wParam, lParam)); }