SetWindowsHookEx C# trap key combinations

G

Guest

Hi,

Can't seem to find any sensible C# examples of this, struggling to work out
the correct way to trap key combinations using SetWindowsHookEx with
WH_KEYBOARD_LL, such as ALT-ESC.

private int InterpretKey(int nCode, IntPtr wParam, IntPtr lParam)
{

.....

hookStruct = (KeyboardHookStruct)Marshal.PtrToStructure(lParam,
typeof(KeyboardHookStruct));

if (hookStruct.vkCode == VK_MENU &&
(hookStruct.flags & VK_ESCAPE ) == hookStruct.flags)
{
handled = true;
....
}

.....

}
 
G

Guest

Ok figured this out, there's different codes for the flag checks.

if (hookStruct.vkCode == ESCAPE &&
(hookStruct.flags & LLKHF_ALTDOWN) == hookStruct.flags)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top