ThinkVantage Key and SetWindowsHookEx

Performance, hardware, software, general buying and gaming discussion..
Post Reply
Message
Author
jeffm
Freshman Member
Posts: 112
Joined: Wed Feb 07, 2007 9:13 pm
Location: Columbia, SC
Contact:

ThinkVantage Key and SetWindowsHookEx

#1 Post by jeffm » Wed Mar 14, 2007 4:07 pm

I wrote a small c++ program to trap a ThinkVantage key press, but pressing the key does not generate any keyboard input. Has anyone else tried this?

I'm working on a clean-install so I may be missing a driver. Although, I did install the hotkey driver and the keyboard customizer utility.

Here's the hook procedure:

LRESULT CALLBACK LowLevelKeyboardProc(int nCode, WPARAM wParam, LPARAM lParam)
{
if( nCode < 0 )
{
return ::CallNextHookEx(g_keyboardHook, nCode, wParam, lParam );
}

KBDLLHOOKSTRUCT* kbd = reinterpret_cast<KBDLLHOOKSTRUCT*>(lParam);
if( kbd->vkCode != THNIKVANTAGE_KEYCODE )
return ::CallNextHookEx(g_keyboardHook, nCode, wParam, lParam );

::ShellExecute(NULL, L"open", L"c:\\windows\\system32\\notepad.exe", NULL, NULL, SW_SHOW);
return STOP_PROCESSING;
}

Puppy
Senior ThinkPadder
Senior ThinkPadder
Posts: 2264
Joined: Sat Oct 30, 2004 4:52 am
Location: Prague, Czech Republic

#2 Post by Puppy » Wed Mar 14, 2007 4:31 pm

Global keyboard hooks might be tricky. Have you tried to monitor all keystrokes to be sure you are checking the right virtual-key code ? Also don't forget you need shared data section for the hook handle because the hook DLL is injected into process with foreground window.

jeffm
Freshman Member
Posts: 112
Joined: Wed Feb 07, 2007 9:13 pm
Location: Columbia, SC
Contact:

#3 Post by jeffm » Wed Mar 14, 2007 4:37 pm

Yeah, I set a breakpoint in the handler to verify the hook is installed properly. I can see all key presses except the ThinkVantage button and the volume control buttons.

Thanks for the reminder on the data segment - forgot about that.

Puppy
Senior ThinkPadder
Senior ThinkPadder
Posts: 2264
Joined: Sat Oct 30, 2004 4:52 am
Location: Prague, Czech Republic

#4 Post by Puppy » Wed Mar 14, 2007 4:40 pm

One possible scenario is that the Keyboard customizer utility does not call CallNextHookEx in the hook DLL (if there is any). I would rather log into a file because I'm not sure the debuuger can handle this.

jeffm
Freshman Member
Posts: 112
Joined: Wed Feb 07, 2007 9:13 pm
Location: Columbia, SC
Contact:

#5 Post by jeffm » Wed Mar 14, 2007 4:52 pm

I disable the keyboard customizer - no change. Good idea though.

Puppy
Senior ThinkPadder
Senior ThinkPadder
Posts: 2264
Joined: Sat Oct 30, 2004 4:52 am
Location: Prague, Czech Republic

#6 Post by Puppy » Wed Mar 14, 2007 5:12 pm

Also I would use WH_KEYBOARD hook instead of WH_KEYBOARD_LL

sugo
ThinkPadder
ThinkPadder
Posts: 1813
Joined: Thu May 27, 2004 11:54 am
Location: Seattle, WA

#7 Post by sugo » Wed Mar 14, 2007 6:16 pm

Perhaps ThinkPad HotKey features ate the keystroke?

If WH_KEYBOARD_LL cannot trap it, I highly doubt WH_KEYBOARD can.

Does "Fn" key generate a call to your LowLevelKeyboardProc?

What are you trying to accomplish? If you want to override the action for ThinkVantage key, changing this value is easier:

[HKEY_LOCAL_MACHINE\SOFTWARE\IBM\TPHOTKEY\8001]
X61

jeffm
Freshman Member
Posts: 112
Joined: Wed Feb 07, 2007 9:13 pm
Location: Columbia, SC
Contact:

#8 Post by jeffm » Wed Mar 14, 2007 7:38 pm

Perhaps ThinkPad HotKey features ate the keystroke?
I've tried disabling it...
Does "Fn" key generate a call to your LowLevelKeyboardProc?
Yes...
If you want to override the action for ThinkVantage key, changing this value is easier:

[HKEY_LOCAL_MACHINE\SOFTWARE\IBM\TPHOTKEY\8001]
That was the first thing I tried. Apparently there's some software that must be installed for that to work (and I'm trying to minimize the number of running processes so I'd rather not install it anyway).

jeffm
Freshman Member
Posts: 112
Joined: Wed Feb 07, 2007 9:13 pm
Location: Columbia, SC
Contact:

#9 Post by jeffm » Thu Mar 15, 2007 4:53 am

I tried WH_KEYBOARD - no luck.

Unix has a utility called tpb that enables the thinkpad button for that platform. Looking at the source for tpb, they are reading from /dev/nvram for the button state. Does anyone know if there is an equivalent operation on Windows?

Here's a link to the relevant source file:

http://www.google.com/codesearch?hl=en& ... inkpad.cpp

Post Reply
  • Similar Topics
    Replies
    Views
    Last post

Return to “Thinkpad - General HARDWARE/SOFTWARE questions”

Who is online

Users browsing this forum: No registered users and 5 guests