Hi,
I've some trouble using the virtual keyboard on few applications that react only on bScan values sent through keybd_event methods (mainly arrows, pg up/down, home/end). According to Microsoft documentation on keybd_event (see next message), I've temporarly fix/changed your SendKey() method to take that in count and now everything's working fine.
Can you please give us the possibility to also [b]specify the bScanCode[/b] when defining keys [b]in a custom TemplateLayout[/b] ? (it would certainly be usefull to have those things in your standard templatelayout)
Here is an extract of the modified SendKey() method (from MindFusion.UI.Wpf.NativeMethods) with "hardcoded" things. I had to give the "KEYEVENTF_EXTENDEDKEY" flag and the right bScan value depending on the keyCode.
[code c++] /// <summary> /// This method send specified key to active vindow /// </summary> /// <param name="keyCode">byte</param> internal static void SendKey(byte keyCode) { ... switch (keyCode) { case 0x10://VK_SHIFT ... default: byte bScan = 0; var keyDownFlag = 0;
if (keyCode is >= 33 and <= 40) { bScan = GetBScanFromKeyCode(keyCode); keyDownFlag = KEYEVENTF_EXTENDEDKEY; }
keybd_event(keyCode, bScan, keyDownFlag, (UIntPtr)0); keybd_event(keyCode, bScan, keyDownFlag | VK_KEYUP, (UIntPtr)0); break; } }
internal static byte GetBScanFromKeyCode(byte keyCode) { return keyCode switch { 33 => 73, //Page Up 34 => 81, //Page Down 35 => 79, //End 36 => 71, //Home 37 => 75, //Arrow Left 38 => 72, //Arrow Up 39 => 77, //Arrow Right 40 => 80, //Arrow Down _ => 0 }; } [/code]
Thank you, Guillaume
|