public static void PressSoftKey(string keystring) { Key key = KeyFromStringNumPadKeyboard(keystring); if (key != Key.None) { byte keyCode = unchecked ((byte)KeyInterop.VirtualKeyFromKey(key)); SoftKeyboardManager.PressAKey(keyCode); } }
public static void PressSoftKey(string keystring, EffectiveKey effectiveKey, bool isshiftpressed, bool iscapslock) { Key key = KeyFromStringFullKeyboard(keystring, effectiveKey, isshiftpressed, iscapslock); if (key != Key.None) { byte keyCode = unchecked ((byte)KeyInterop.VirtualKeyFromKey(key)); //处理输入法切换,不同的系统不同的处理方式 if (key == (Key.LeftShift | Key.LeftCtrl)) { SoftKeyboardManager.PressAKey(16); ////win8-win10Shift //if (OSVersionHelper.IsWindows8OrGreater) //{ // //16是Shift虚拟键值 // SoftKeyboardManager.PressAKey(16); //} ////XP-win7 Shift+Ctrl //else if (OSVersionHelper.IsWindowsXPOrGreater) //{ // byte keyCodectrl = unchecked((byte)KeyInterop.VirtualKeyFromKey(Key.LeftCtrl)); // SoftKeyboardManager.PressDoubleKey(16, keyCodectrl); //} } else { if (!isshiftpressed) { SoftKeyboardManager.PressAKey(keyCode); } else { SoftKeyboardManager.PressDoubleKey(16, keyCode); } } } }