#include <iostream>
#include <Windows.h>
LRESULT CALLBACK MouseProc(int nCode, WPARAM wParam, LPARAM lParam) {
if (nCode >= 0) {
if (wParam == WM_MOUSEWHEEL) {
int delta = GET_WHEEL_DELTA_WPARAM(wParam);
if (delta > 0) {
std::cout << "Wheel scrolled up: " << delta << std::endl;
}
else if (delta < 0) {
std::cout << "Wheel scrolled down: " << -delta << std::endl;
}
}
}
return CallNextHookEx(NULL, nCode, wParam, lParam);
}
int main() {
HHOOK hook = SetWindowsHookEx(WH_MOUSE_LL, MouseProc, NULL, 0);
if (hook == NULL) {
std::cerr << "Failed to set hook!" << std::endl;
return -1;
}
MSG msg;
while (GetMessage(&msg, NULL, 0, 0) != 0) {
TranslateMessage(&msg);
DispatchMessage(&msg);
}
UnhookWindowsHookEx(hook);
return 0;
}