locked
catching Hangup key: VK_TEND RRS feed

  • Question

  • Hi all,

    I am looking for some help with hardware key handling on WM5.0 PPC.
    I am trying to catch the hangup key VK_TEND.

    I found this method on one forum:

    void ReleaseRedKey()
    {
       typedef BOOL (__stdcall *UnregisterFunc1Proc)( UINT, UINT );
       HINSTANCE hCoreDll;
       UnregisterFunc1Proc procUndergisterFunc;
       hCoreDll = LoadLibrary(_T("coredll.dll"));
       ASSERT(hCoreDll);
       procUndergisterFunc = (UnregisterFunc1Proc)GetProcAddress( hCoreDll, _T("UnregisterFunc1"));
       ASSERT(procUndergisterFunc); 

       procUndergisterFunc(0, VK_TEND);
       ::UnregisterHotKey(m_hWnd, VK_TEND);

    At last, I want to give back the other applications the ability to use the same key. Unfortunately, I am unable to deregister that key with the previous method.
    Well now I am stuck and I have no clue to catch properly this key.

    If one of you have an idea ...

    regards,

    olive2

    Monday, October 22, 2007 2:39 PM

Answers

  • You can start with code based on that article: http://www.codeproject.com/samples/ForTheKids.asp

    You would have to copy the following declarations and defines:

    Code Block

    #define WH_KEYBOARD_LL 20

    extern "C"

    {

    typedef LRESULT (CALLBACK* HOOKPROC)(int code, WPARAM wParam, LPARAM lParam);

    typedef struct tagKBDLLHOOKSTRUCT

    {

    DWORD vkCode; // virtual key code

    DWORD scanCode; // scan code

    DWORD flags; // flags

    DWORD time; // time stamp for this message

    DWORD dwExtraInfo; // extra info from the driver or keybd_event

    } KBDLLHOOKSTRUCT, *PKBDLLHOOKSTRUCT;

    HHOOK WINAPI SetWindowsHookExW( int idHook, HOOKPROC lpfn, HINSTANCE hmod, DWORD dwThreadId );

    BOOL WINAPI UnhookWindowsHookEx( HHOOK hhk );

    LRESULT WINAPI CallNextHookEx( HHOOK hhk, int nCode, WPARAM wParam, LPARAM lParam );

    LRESULT CALLBACK KeyboardProc( int code, WPARAM wParam, LPARAM lParam );

    #define SetWindowsHookEx SetWindowsHookExW

    }

    HHOOK hKeyboardHook = 0;

    #define HC_ACTION 0

     

     

    Than just call

    Code Block

    hKeyboardHook = SetWindowsHookExW( WH_KEYBOARD_LL, (HOOKPROC) KeyboardProc, NULL, 0 );

     

     

    KeyboardProc is the LowLevelKeyboardProc mentioned in the article. Modify it to your needs.

    Monday, October 22, 2007 3:21 PM

All replies

  • You can start with code based on that article: http://www.codeproject.com/samples/ForTheKids.asp

    You would have to copy the following declarations and defines:

    Code Block

    #define WH_KEYBOARD_LL 20

    extern "C"

    {

    typedef LRESULT (CALLBACK* HOOKPROC)(int code, WPARAM wParam, LPARAM lParam);

    typedef struct tagKBDLLHOOKSTRUCT

    {

    DWORD vkCode; // virtual key code

    DWORD scanCode; // scan code

    DWORD flags; // flags

    DWORD time; // time stamp for this message

    DWORD dwExtraInfo; // extra info from the driver or keybd_event

    } KBDLLHOOKSTRUCT, *PKBDLLHOOKSTRUCT;

    HHOOK WINAPI SetWindowsHookExW( int idHook, HOOKPROC lpfn, HINSTANCE hmod, DWORD dwThreadId );

    BOOL WINAPI UnhookWindowsHookEx( HHOOK hhk );

    LRESULT WINAPI CallNextHookEx( HHOOK hhk, int nCode, WPARAM wParam, LPARAM lParam );

    LRESULT CALLBACK KeyboardProc( int code, WPARAM wParam, LPARAM lParam );

    #define SetWindowsHookEx SetWindowsHookExW

    }

    HHOOK hKeyboardHook = 0;

    #define HC_ACTION 0

     

     

    Than just call

    Code Block

    hKeyboardHook = SetWindowsHookExW( WH_KEYBOARD_LL, (HOOKPROC) KeyboardProc, NULL, 0 );

     

     

    KeyboardProc is the LowLevelKeyboardProc mentioned in the article. Modify it to your needs.

    Monday, October 22, 2007 3:21 PM
  • Thank you for your help Patrick,

    regards,

    olive2

     

    Tuesday, October 23, 2007 2:34 PM
  • Unfortunately, this method does not work on Moto Q9. Is there any other way to intercept END key on Q9?

     

    (It works fine on Blackjack 2)

    Wednesday, June 4, 2008 11:28 PM
  • What exactly is not working? Do you get an error?

    Is you App signed as privileged?

    Thursday, June 5, 2008 7:06 AM
  • No,

    When a key is pressed, I don't get a callback to LRESULT CALLBACK KeyboardProc

     

    Monday, June 9, 2008 2:48 PM
  • Does the SetWindowsHookEx Call work? Do you get an result?

    Sign you app as privileged to ensure you have the rights to hook.

    Tuesday, June 10, 2008 6:55 AM
  • No it didn't work. I didn't get back any result

     

    Friday, June 27, 2008 7:38 PM
  • So the HHOOK return value is NULL?

    What do you get using GetLastError?

    Saturday, June 28, 2008 3:50 PM