CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 15 of 17

Threaded View

  1. #1
    Join Date
    Mar 2005
    Posts
    9

    Question I have a real problem with hooks

    Hi all,
    i'm trying to monitor the system for hotkeys like powerstrip it monitors for hotkeys to increase or decrease gamma or whatever while any thing is active the first thing i thought about was hooks so i wrote my hook procedure in a dll setup the hook like this

    ///code in exe
    gkbhookdll = LoadLibrary("kbhook.dll");//load dll
    gkeyboardhook = SetWindowsHookEx(WH_KEYBOARD,(HOOKPROC)GetProcAddress(gkbhookdll,"KeyProc"),gkbhookdll,0);

    i specified 0 for last parameter to be system wide every thing was ok

    ///code in dll
    LRESULT CALLBACK KeyProc(int nCode,WPARAM wParam,LPARAM lParam)
    {
    MessageBox(NULL,"called hook","called hook",MB_OK);
    return CallNextHookEx(0,nCode,wParam,lParam);
    }

    now strange problem is that when i activate another window then the hook doesn't work even if i reactivated my window, any one knows what's happening.
    does CallNextHookEx returns something that Unhooks my hook?
    Thanks for advance and if any one knows a better way for monitoring system for specific hotkeys please tell me, thanks every body again.
    and if some body knows how to format parameters returned from the hook with CHotKeyCtrl.GetHotKey is welcome because of the parameter holding wModifiers.
    The hook can only give you the code of one button and tell you if alt is pressed. Thanks for the third time.
    Last edited by snakekain; March 4th, 2005 at 07:43 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured