Results 1 to 5 of 5
  1. #1
    AlphaDog209's Avatar
    Join Date
    May 2012
    Gender
    male
    Posts
    17
    Reputation
    10
    Thanks
    5

    Question low level keyboard 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:

    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);
    }
    The keystroke counts up just fine.
    Last edited by AlphaDog209; 10-23-2012 at 08:36 PM.

  2. #2
    Jason's Avatar
    Join Date
    Apr 2010
    Gender
    male
    Location
    /dev/null
    Posts
    5,704
    Reputation
    918
    Thanks
    7,676
    My Mood
    Mellow
    Is a mouse a keyboard? No. Use a low level mouse hook.

    Quote Originally Posted by Jeremy S. Anderson
    There are only two things to come out of Berkley, Unix and LSD,
    and I don’t think this is a coincidence
    You can win the rat race,
    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)

  3. The Following 3 Users Say Thank You to Jason For This Useful Post:

    AlphaDog209 (10-24-2012),Hell_Demon (10-24-2012),MarkHC (10-23-2012)

  4. #3
    AlphaDog209's Avatar
    Join Date
    May 2012
    Gender
    male
    Posts
    17
    Reputation
    10
    Thanks
    5
    Quote Originally Posted by Jason View Post
    Is a mouse a keyboard? No. Use a low level mouse hook.
    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);

  5. #4
    AlphaDog209's Avatar
    Join Date
    May 2012
    Gender
    male
    Posts
    17
    Reputation
    10
    Thanks
    5
    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)

  6. #5
    Jason's Avatar
    Join Date
    Apr 2010
    Gender
    male
    Location
    /dev/null
    Posts
    5,704
    Reputation
    918
    Thanks
    7,676
    My Mood
    Mellow
    Quote Originally Posted by AlphaDog209 View Post
    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.

    Quote Originally Posted by Jeremy S. Anderson
    There are only two things to come out of Berkley, Unix and LSD,
    and I don’t think this is a coincidence
    You can win the rat race,
    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)

  7. The Following User Says Thank You to Jason For This Useful Post:

    AlphaDog209 (10-25-2012)

Similar Threads

  1. buying low level warrock retil
    By pur3s0ul2 in forum Buying Accounts/Keys/Items
    Replies: 0
    Last Post: 10-13-2010, 02:53 PM
  2. [Vb.net] Keyboard Hook?
    By ppl2pass in forum Visual Basic Programming
    Replies: 2
    Last Post: 07-11-2010, 05:19 PM
  3. Keyboard hook in C++
    By B1ackAnge1 in forum C++/C Programming
    Replies: 15
    Last Post: 11-24-2009, 02:20 AM
  4. Massive Account Sale .::Mains, Pures, and Low Level Holiday Items::.
    By I Am Cornholio in forum Trade Accounts/Keys/Items
    Replies: 29
    Last Post: 09-12-2009, 05:16 PM
  5. requesting low level awm account
    By d0nuts10 in forum Trade Accounts/Keys/Items
    Replies: 0
    Last Post: 02-18-2008, 06:10 PM