private void ReplaceKeyDownToKeyPress(IRecorderItem item) { IKeyRecorderItem keyItem = item as IKeyRecorderItem; IRecorderItem newItem = new KeyPressRecorderItem() { Dir = Dir.Press, VkCode = keyItem.VkCode, Keyname = keyItem.Keyname, UnicodeCharacter = keyItem.UnicodeCharacter, ModifierKeys = keyItem.ModifierKeys }; this.ESRRecorder.ReplaceItem(item, newItem); }
public override bool Play(ESRPlayer player) { //Waiting player.WaitingPlaying(this); //Action ActionVkCode(this); foreach (var i in this.ChildItems) { if (!player.IsThreadEnable) { return(false); } KeyPressRecorderItem item = i as KeyPressRecorderItem; //Waiting player.WaitingPlaying(item); //Action ActionVkCode(item); } return(true); }
public void Add(KeyInputEventArgs e) { IRecorderItem newRecorder = null; if (e.KeyData.EventType == KeyEvent.up) { if (IsIncludedKeyItem(e)) { ALog.Debug("KeyEvent.Up.IsIncludedKeyItem == true"); return; } IRecorderItem prevRecorder = GetPrviousKeyDownItem(e); if (prevRecorder != null) { //Delete Previous Key up Items ALog.Debug("Delete Items::Recorder={0}, VkCode={1}", prevRecorder.Recorder, AUtil.ToVKeyToString((prevRecorder as IKeyRecorderItem).VkCode)); this.ESRRecorder.DeleteItem(prevRecorder); //New Key Press this.ESRRecorder.ResetCurrentRecorderbyLast(); newRecorder = new KeyPressRecorderItem() { Dir = Dir.Press, VkCode = e.KeyData.VkCode, Keyname = e.KeyData.Keyname, UnicodeCharacter = e.KeyData.UnicodeCharacter, ModifierKeys = Control.ModifierKeys }; //If Current Is KeyPress, this KeyPress add into ChildItem if (this.CurrentRecorder?.Recorder == RecorderType.KeyPress) { ALog.Debug("Add KeyPress into KeyPress.ChildItem"); this.ESRRecorder.ResetWaitingTime(); this.CurrentRecorder.ChildItems.Add(newRecorder); this.ESRRecorder.UpdateItem(this.CurrentRecorder); return; } } else { ALog.Debug("KeyUp Item"); newRecorder = new KeyUpDownRecorderItem() { Dir = Dir.Up, VkCode = e.KeyData.VkCode, Keyname = e.KeyData.Keyname, UnicodeCharacter = e.KeyData.UnicodeCharacter, ModifierKeys = Control.ModifierKeys }; } } else { //it's state on pressing key if (IsLastSameKeyDown(e.KeyData.VkCode)) { ALog.Debug("KeyEvent.Down, IsLastKeyDown: True"); return; } //If current is KeyPress, Add a item into ChildItem if (IsCurrentKeyPress() && !IsCtrlAltShift(e.KeyData.VkCode) && !IsCtrlAltShift(Control.ModifierKeys)) { //New Key Press this.ESRRecorder.ResetCurrentRecorderbyLast(); newRecorder = new KeyPressRecorderItem() { Dir = Dir.Press, VkCode = e.KeyData.VkCode, Keyname = e.KeyData.Keyname, UnicodeCharacter = e.KeyData.UnicodeCharacter, ModifierKeys = Control.ModifierKeys }; this.ESRRecorder.ResetWaitingTime(); this.CurrentRecorder.ChildItems.Add(newRecorder); this.ESRRecorder.UpdateItem(this.CurrentRecorder); return; } //If Current is Key Down, It means continuosly 2 item's Type is KeyDown. //So that, 1) Replace Previous KeyDown item to KeyPress // 2) Add a this time KeyDown item into Child Item if (IsCurrentKeyDown() && !IsCtrlAltShift(e.KeyData.VkCode) && !IsCtrlAltShift(Control.ModifierKeys)) { ReplaceKeyDownToKeyPress(this.CurrentRecorder); //New Key Press this.ESRRecorder.ResetCurrentRecorderbyLast(); newRecorder = new KeyPressRecorderItem() { Dir = Dir.Press, VkCode = e.KeyData.VkCode, Keyname = e.KeyData.Keyname, UnicodeCharacter = e.KeyData.UnicodeCharacter, ModifierKeys = Control.ModifierKeys }; this.ESRRecorder.ResetWaitingTime(); this.CurrentRecorder.ChildItems.Add(newRecorder); this.ESRRecorder.UpdateItem(this.CurrentRecorder); return; } //New Key Down newRecorder = new KeyUpDownRecorderItem() { Dir = Dir.Down, VkCode = e.KeyData.VkCode, Keyname = e.KeyData.Keyname, UnicodeCharacter = e.KeyData.UnicodeCharacter, ModifierKeys = Control.ModifierKeys }; } this.ESRRecorder.AddKeyItem(newRecorder); }
private void ActionVkCode(KeyPressRecorderItem item) { GM.Instance.InputSimulator.Keyboard.KeyPress((VirtualKeyCode)item.VkCode); }