I’m setting up multiple hotkeys in my application using registerHotKey
Win32.RegisterHotKey(hWndSource.Handle, add, Win32.MOD_CONTROL | Win32.MOD_SHIFT, Win32.VK_KEY_D);
Win32.RegisterHotKey(hWndSource.Handle, manage, Win32.MOD_CONTROL | Win32.MOD_SHIFT, Win32.VK_KEY_M);
This is all find and dandy, but I’m confused with how I am supposed to catch each one. Here is the proc that occurs when a hotkey is pressed:
private IntPtr MainWindowProcCatchManageHotkey(IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam, ref bool handled)
{
switch (msg)
{
case Win32.WM_HOTKEY:
if (wParam == (IntPtr)(-16285))
{
CaptureManageHotkey();
}
if (wParam == (IntPtr)(-16303))
{
CaptureSelection();
}
handled = true;
break;
}
return IntPtr.Zero;
}
This is pretty ghetto. It works from the little I’ve tested it, but I’m not willing to push it without a better understanding of what is happening. The only reason I know what values to test wParam against is because I ran the debugger and set a breakpoint so I could see what was being passed into the function. Is there somewhere I can look up the values for lParam and wParam in my case? I want to catch ctrl+shift+d for one, and ctrl+shift+m for another. Where can I see what the lParam and wParam for those should be?
tl;dr How can I know what values of lParam and wParam I want to look for?
The
wParamvalues are theidvalues you passed when you calledRegisterHotKey. In this case they are the valuesaddandmanage.The
lParamvalue contains the key combination that was actually pressed.It’s all explained in the MSDN topic for
WM_HOTKEY.