Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. KBDLLHOOKSTRUCT error why?

KBDLLHOOKSTRUCT error why?

Scheduled Pinned Locked Moved C / C++ / MFC
helpquestion
3 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Z Offline
    Z Offline
    zubeido
    wrote on last edited by
    #1

    HHOOK hKeyHook; __declspec(dllexport) LRESULT CALLBACK KeyEvent (int nCode,WPARAM wParam, LPARAM lParam) { if( (nCode= HC_ACTION) && ( (wParam = WM_SYSKEYDOWN) || (wParam = WM_KEYDOWN) ) ) { KBDLLHOOKSTRUCT hooked *= *((KBDLLHOOKSTRUCT*)lParam); DWORD dwMsg; dwMsg += hooked.scanCode <<16; dwMsg += hooked.flags << 24; char lpszName[0x100] = {0}; lpszName[0] = '['; int i= GetKeyNameText(dwMsg,(lpszName+1),0xff) +1; lpszName[i] = ']'; printf(lpszName); } I want to hook the keyboard but the KBDLLHOOKSTRUCT struct keeps giving error even with the intelisense showing the members of the struct. I dont really get it Here are the errors error C2065: 'KBDLLHOOKSTRUCT' : undeclared identifier error C2059: syntax error : ')' among other stupid errors. Can anyone help me? Tks in advance

    A B 2 Replies Last reply
    0
    • Z zubeido

      HHOOK hKeyHook; __declspec(dllexport) LRESULT CALLBACK KeyEvent (int nCode,WPARAM wParam, LPARAM lParam) { if( (nCode= HC_ACTION) && ( (wParam = WM_SYSKEYDOWN) || (wParam = WM_KEYDOWN) ) ) { KBDLLHOOKSTRUCT hooked *= *((KBDLLHOOKSTRUCT*)lParam); DWORD dwMsg; dwMsg += hooked.scanCode <<16; dwMsg += hooked.flags << 24; char lpszName[0x100] = {0}; lpszName[0] = '['; int i= GetKeyNameText(dwMsg,(lpszName+1),0xff) +1; lpszName[i] = ']'; printf(lpszName); } I want to hook the keyboard but the KBDLLHOOKSTRUCT struct keeps giving error even with the intelisense showing the members of the struct. I dont really get it Here are the errors error C2065: 'KBDLLHOOKSTRUCT' : undeclared identifier error C2059: syntax error : ')' among other stupid errors. Can anyone help me? Tks in advance

      A Offline
      A Offline
      Anonymous
      wrote on last edited by
      #2

      This line is incorrect: KBDLLHOOKSTRUCT hooked *= *((KBDLLHOOKSTRUCT*)lParam); Change it to: KBDLLHOOKSTRUCT* hooked = (KBDLLHOOKSTRUCT*)lParam; This should clear up the errors. Regards, -John

      1 Reply Last reply
      0
      • Z zubeido

        HHOOK hKeyHook; __declspec(dllexport) LRESULT CALLBACK KeyEvent (int nCode,WPARAM wParam, LPARAM lParam) { if( (nCode= HC_ACTION) && ( (wParam = WM_SYSKEYDOWN) || (wParam = WM_KEYDOWN) ) ) { KBDLLHOOKSTRUCT hooked *= *((KBDLLHOOKSTRUCT*)lParam); DWORD dwMsg; dwMsg += hooked.scanCode <<16; dwMsg += hooked.flags << 24; char lpszName[0x100] = {0}; lpszName[0] = '['; int i= GetKeyNameText(dwMsg,(lpszName+1),0xff) +1; lpszName[i] = ']'; printf(lpszName); } I want to hook the keyboard but the KBDLLHOOKSTRUCT struct keeps giving error even with the intelisense showing the members of the struct. I dont really get it Here are the errors error C2065: 'KBDLLHOOKSTRUCT' : undeclared identifier error C2059: syntax error : ')' among other stupid errors. Can anyone help me? Tks in advance

        B Offline
        B Offline
        Blake Miller
        wrote on last edited by
        #3

        Also, your IF statements are goofed up... Which immediately lets me know you did not turn your warning level to 4 or you are ignoring WARNINGS during your mopile, because the compiler would otherwise warn you about "Assignment within conditional expression". Try changing this: if( (nCode= HC_ACTION) && ( (wParam = WM_SYSKEYDOWN) || (wParam = WM_KEYDOWN) ) ) to this: if( (nCode == HC_ACTION) && ( (wParam == WM_SYSKEYDOWN) || (wParam == WM_KEYDOWN) ) ) I usually try to place the contant on the left hand side, because such code will NOT compile if you made such a similar error: if( (HC_ACTION == nCode) && ( (WM_SYSKEYDOWN == wParam) || (WM_KEYDOWN == wParam) ) ) Since your IF is wacked, you are probably processing messages you should not be, at times.

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups