public static ApplicationAction FromString(ApplicationController controller, string value) { KeyInput retVal = new KeyInput(controller); var split = value.Trim().Split(' '); foreach (var item in split) { var param = retVal.GetParameterFromString(item); ushort iValue; if (ushort.TryParse(param, NumberStyles.AllowHexSpecifier, null, out iValue)) retVal.AddKey((WindowsAPI.VirtualKeyCode)iValue); } return retVal; }
public KeyInput AddKey(KeyInput input) { if (input != null) { bool foundModifier = false; if (KeyCount > 0) { for (int i = _input.Count - 1; i >= 0; i--) { if (_input[i].Data.Keyboard.Flags == 0 && ( (ushort)WindowsAPI.VirtualKeyCode.VK_SHIFT == _input[i].Data.Keyboard.KeyCode || (ushort)WindowsAPI.VirtualKeyCode.VK_LSHIFT == _input[i].Data.Keyboard.KeyCode || (ushort)WindowsAPI.VirtualKeyCode.VK_RSHIFT == _input[i].Data.Keyboard.KeyCode || (ushort)WindowsAPI.VirtualKeyCode.VK_CONTROL == _input[i].Data.Keyboard.KeyCode || (ushort)WindowsAPI.VirtualKeyCode.VK_LCONTROL == _input[i].Data.Keyboard.KeyCode || (ushort)WindowsAPI.VirtualKeyCode.VK_RCONTROL == _input[i].Data.Keyboard.KeyCode || (ushort)WindowsAPI.VirtualKeyCode.VK_MENU == _input[i].Data.Keyboard.KeyCode || (ushort)WindowsAPI.VirtualKeyCode.VK_LMENU == _input[i].Data.Keyboard.KeyCode || (ushort)WindowsAPI.VirtualKeyCode.VK_RMENU == _input[i].Data.Keyboard.KeyCode )) { foundModifier = true; _input.Insert(i+1, input._input[0]); _input.Insert(i+2, input._input[1]); break; } } } if (!foundModifier) { _input.Add(input._input[0]); _input.Add(input._input[1]); } } return this; }
public ApplicationInput AddKey(WindowsAPI.VirtualKeyCode keyCode) { var key = new KeyInput(Controller, keyCode); if (!key.Empty()) Append(key); return this; }
public KeyInput AddKey(KeyInput input) { if (input != null) { foreach (var item in input._input) _input.Add(item); } return this; }