So I'm building an app that will eventually become a sort of docked On Screen Keyboard containing user-specified keys (part of my car-puter project).
So far so good, I can P/invoke keybd_event just fine for most keys, including Windows, print screen, etc.
The problem: certain keys such as VK_LAUNCH_MEDIA_SELECT and VK_LAUNCH_APP1 aren't working at all.
I'm using the same call as the other keys, so why is Windows being daft with just these "special" keys?
Further clarification: I'm not trying to capture keypresses, I'm sending them.
NativeMethods.keybd_event(this.Settings.vKey, 0, 0 | NativeMethods.KEYEVENTF_EXTENDEDKEY, (IntPtr)0);
NativeMethods.keybd_event(this.Settings.vKey, 0, NativeMethods.KEYEVENTF_KEYUP | NativeMethods.KEYEVENTF_EXTENDEDKEY, (IntPtr)0);
Where vKey is a char of a virtual keycode, such as VK_LAUNCH_APP1 (0xB6)
. I'm not sure if EXTENDEDKEY is really necessary since I don't think those specific keys are considered "extended" (i.e. Right-alt, Right-shift, etc)
VK_LAUNCH_APP1 (on Windows 10) will start File Explorer, no "Vendor provided program" needs to be present (other than Windows). Similarly, VK_LAUNCH_MEDIA_SELECT (0xB5)
opens Windows Media Player (or whatever media player you have set in the Settings control panel).