Advertisement
Guest User

Rudimentary Mouse Hook

a guest
Jul 21st, 2012
218
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.58 KB | None | 0 0
  1. #include <windows.h>
  2.  
  3. LRESULT CALLBACK mouseProc (int nCode, WPARAM wParam, LPARAM lParam) {
  4.     return 1;
  5. }
  6.  
  7. DWORD WINAPI hookThread (LPVOID param) {
  8.     HHOOK mouseHook = SetWindowsHookEx (WH_MOUSE_LL, mouseProc, GetModuleHandle (NULL), 0);
  9.  
  10.     MSG message;
  11.     while (GetMessage (&message, NULL, 0, 0)) {
  12.         TranslateMessage (&message);
  13.         DispatchMessage (&message);
  14.     }
  15.  
  16.     UnhookWindowsHookEx (mouseHook);
  17.     return 0;
  18. }
  19.  
  20. int main() {
  21.     HANDLE thread = CreateThread (NULL, 0, hookThread, NULL, 0, NULL);
  22.     WaitForSingleObject (thread, INFINITE);
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement