I call the code below and it connects to WM_MOUSEWHEEL accordingly. The problem I am facing is that even if I send a scroll message in one direction (-120), the scroll wheel works as expected. I set breakpoints and ifs in it and work as expected.
private delegate IntPtr LowLevelMouseProc(int nCode, IntPtr wParam, IntPtr lParam); private static IntPtr HookCallback( int nCode, IntPtr wParam, IntPtr lParam) { if (nCode >= 0 && MouseMessages.WM_MOUSEWHEEL == (MouseMessages)wParam) { MSLLHOOKSTRUCT hookStruct = (MSLLHOOKSTRUCT)Marshal.PtrToStructure(lParam, typeof(MSLLHOOKSTRUCT)); Console.WriteLine(hookStruct.mouseData); INPUT[] input; input = new INPUT[1]; input[0].type = INPUT_MOUSE; input[0].mi.dx = 0; input[0].mi.dy = 0; input[0].mi.dwFlags = MOUSEEVENTF_WHEEL; input[0].mi.time = 0; input[0].mi.dwExtraInfo = 0; input[0].mi.mouseData = -120; SendInput(1, input, Marshal.SizeOf(input)); return (IntPtr)1;
source share