private string BuildInputText(StandardBindingInfo keyInfo) { var inputText = ""; if (keyInfo.Primary.Device == "Keyboard") { inputText = "{" + keyInfo.Primary.Key.Replace("Key_", "DIK") + "}"; foreach (var m in keyInfo.Primary.Modifier) { if (m.Device == "Keyboard") { inputText = "{" + m.Key.Replace("Key_", "DIK") + "}" + inputText; } } } else if (keyInfo.Secondary.Device == "Keyboard") { inputText = "{" + keyInfo.Secondary.Key.Replace("Key_", "DIK") + "}"; foreach (var m in keyInfo.Secondary.Modifier) { if (m.Device == "Keyboard") { inputText = "{" + m.Key.Replace("Key_", "DIK") + "}" + inputText; } } } if (!string.IsNullOrEmpty(inputText)) { inputText = inputText.Replace("_", "") .Replace("Subtract", "MINUS") //DIKNumpadSubtract -> DikNumpadMinus .Replace("Add", "PLUS") //DIKNumpadAdd -> DikNumpadPlus .Replace("Divide", "SLASH") //DIKNumpadDivide -> DikNumpadSlash .Replace("Decimal", "PERIOD") //DIKNumpadDecimal -> DikNumpadPeriod .Replace("Multiply", "STAR") //DIKNumpadMultiply -> DikNumpadStar .Replace("Enter", "RETURN") .Replace("Backspace", "BACK") .Replace("UpArrow", "UP") .Replace("DownArrow", "DOWN") .Replace("LeftArrow", "LEFT") .Replace("RightArrow", "RIGHT") .Replace("LeftAlt", "LMENU") .Replace("RightAlt", "RMENU") .Replace("RightControl", "RCONTROL") .Replace("LeftControl", "LCONTROL") .Replace("RightShift", "RSHIFT") .Replace("LeftShift", "LSHIFT"); //Logger.Instance.LogMessage(TracingLevel.DEBUG, $"{inputText}"); } return(inputText); }
protected void SendKeypressUp(StandardBindingInfo keyInfo) { var inputText = BuildInputText(keyInfo); if (!string.IsNullOrEmpty(inputText)) { SendInputUp("{" + inputText + "}"); } }
protected void SendKeypress(StandardBindingInfo keyInfo, int repeatCount = 1) { var inputText = BuildInputText(keyInfo); if (!string.IsNullOrEmpty(inputText)) { //Logger.Instance.LogMessage(TracingLevel.DEBUG, $"{inputText}"); for (var i = 0; i < repeatCount; i++) { if (repeatCount > 1 && i > 0) { Thread.Sleep(20); } SendInput("{" + inputText + "}"); } // keyboard test page : https://w3c.github.io/uievents/tools/key-event-viewer.html } }
protected void SendKeypress(StandardBindingInfo keyInfo, int repeatCount = 1) { var inputText = ""; if (keyInfo.Primary.Device == "Keyboard") { inputText = "{" + keyInfo.Primary.Key.Replace("Key_", "DIK") + "}"; foreach (var m in keyInfo.Primary.Modifier) { if (m.Device == "Keyboard") { inputText = "{" + m.Key.Replace("Key_", "DIK") + "}" + inputText; } } } else if (keyInfo.Secondary.Device == "Keyboard") { inputText = "{" + keyInfo.Secondary.Key.Replace("Key_", "DIK") + "}"; foreach (var m in keyInfo.Secondary.Modifier) { if (m.Device == "Keyboard") { inputText = "{" + m.Key.Replace("Key_", "DIK") + "}" + inputText; } } } if (!string.IsNullOrEmpty(inputText)) { inputText = inputText.Replace("_", "") .Replace("Subtract", "MINUS") //DIKNumpadSubtract -> DikNumpadMinus .Replace("Add", "PLUS") //DIKNumpadAdd -> DikNumpadPlus .Replace("Divide", "SLASH") //DIKNumpadDivide -> DikNumpadSlash .Replace("Decimal", "PERIOD") //DIKNumpadDecimal -> DikNumpadPeriod .Replace("Multiply", "STAR") //DIKNumpadMultiply -> DikNumpadStar .Replace("Enter", "RETURN") .Replace("Backspace", "BACK") .Replace("UpArrow", "UP") .Replace("DownArrow", "DOWN") .Replace("LeftArrow", "LEFT") .Replace("RightArrow", "RIGHT") .Replace("LeftAlt", "LMENU") .Replace("RightAlt", "RMENU") .Replace("RightControl", "RCONTROL") .Replace("LeftControl", "LCONTROL") .Replace("RightShift", "RSHIFT") .Replace("LeftShift", "LSHIFT"); //Logger.Instance.LogMessage(TracingLevel.DEBUG, $"{inputText}"); for (var i = 0; i < repeatCount; i++) { if (repeatCount > 1 && i > 0) { Thread.Sleep(20); } SendInput("{" + inputText + "}"); } // keyboard test page : https://w3c.github.io/uievents/tools/key-event-viewer.html } }