Is a mouse a keyboard? No. Use a low level mouse hook.
Im making a simple logger that logs the amount of key pressed, and the amount of mouse clicks.
I got my hook working, and all the keys are being logged, but i dont know how to log the mouse clicks:S
I tried the following:
The keystroke counts up just fine.Code:LRESULT CALLBACK keyboardHookProc(int nCode, WPARAM wParam, LPARAM lParam){ PKBDLLHOOKSTRUCT p = (PKBDLLHOOKSTRUCT) lParam; if (nCode==HC_ACTION){ if (wParam == WM_KEYDOWN){ switch (p->vkCode) { case VK_LBUTTON: cout << l++ << endl; break; case VK_MBUTTON: cout << m++ << endl; break; case VK_RBUTTON: cout << r++ << endl; break; default: cout << keystroke++ << endl;; } } } return CallNextHookEx(NULL, nCode, wParam, lParam); }
Last edited by AlphaDog209; 10-23-2012 at 08:36 PM.
Is a mouse a keyboard? No. Use a low level mouse hook.
You can win the rat race,Originally Posted by Jeremy S. Anderson
But you're still nothing but a fucking RAT.
++Latest Projects++
[Open Source] Injection Library
Simple PE Cipher
FilthyHooker - Simple Hooking Class
CLR Injector - Inject .NET dlls with ease
Simple Injection - An in-depth look
MPGH's .NET SDK
eJect - Simple Injector
Basic PE Explorer (BETA)
AlphaDog209 (10-24-2012),Hell_Demon (10-24-2012),MarkHC (10-23-2012)
ofc -_- so stupid of me.
Got it working now
Code:LRESULT CALLBACK mouseHookProc(int nCode, WPARAM wParam, LPARAM lParam){ PKBDLLHOOKSTRUCT p = (PKBDLLHOOKSTRUCT) lParam; if (nCode==HC_ACTION){ switch (wParam){ case WM_LBUTTONDOWN: l++ << endl; break; case WM_RBUTTONDOWN: r++ << endl; break; } } return CallNextHookEx(NULL, nCode, wParam, lParam); }Code:HHOOK mouseHook = SetWindowsHookEx(WH_MOUSE_LL, (HOOKPROC)mouseHookProc, hInstance, 0);
One more question. This hook doesnt work when im playing a game, is this because the game uses the same kind of hook?
Is there an easy way to check if buttons are pressed in any game? (not just one specific game)
SetWindowsHook relies on the program using the Windows Messaging Queue to handle input. If the application is something like a DirectX game, it may use an alternate method of trapping input, such as DirectInput. In such a case, a hook set by SetWindowsHook won't know anything happened.
You can win the rat race,Originally Posted by Jeremy S. Anderson
But you're still nothing but a fucking RAT.
++Latest Projects++
[Open Source] Injection Library
Simple PE Cipher
FilthyHooker - Simple Hooking Class
CLR Injector - Inject .NET dlls with ease
Simple Injection - An in-depth look
MPGH's .NET SDK
eJect - Simple Injector
Basic PE Explorer (BETA)
AlphaDog209 (10-25-2012)