Source.c 568 B

123456789101112131415161718192021
  1. #include <Windows.h>
  2. #include <Stdio.h>
  3. LRESULT CALLBACK LogMouse(int iCode, WPARAM wParam, LPARAM lParam);
  4. int main() {
  5. }
  6. int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PSTR pCmdLine, int nCmdShow)
  7. {
  8. HHOOK hHOOK = SetWindowsHookExW(WH_MOUSE_LL, LogMouse, NULL, NULL);
  9. }
  10. LRESULT CALLBACK LogMouse(int iCode, WPARAM wParam, LPARAM lParam) {
  11. KBDLLHOOKSTRUCT* p = (KBDLLHOOKSTRUCT*)lParam;
  12. int iKey = MapVirtualKeyA(p->vkCode, NULL);
  13. WCHAR procID[256];
  14. swprintf_s(procID, 256, L"%d", iKey);
  15. MessageBox(NULL, procID, L"Key Pressed", MB_OK);
  16. }