private void buttonPlay_Click(object sender, RoutedEventArgs e) { ALog.Debug(""); bool isReset = this.Recorder.State != ESRState.PlayingPause; this.Recorder.StartPlaying(isReset); }
public void MouseInput(EventHook.MouseEventArgs e) { if (e.Message == GetMouseMessages()) { if (this.IsIgnoreMouseRecorder) { this.RemainedIgnoreMouseButtonDownCount--; if (this.RemainedIgnoreMouseButtonDownCount >= 0) { ALog.Debug("MouseWatcher::IsIgnoreMouseRecorder is true!"); return; } } this.IsIgnoreMouseRecorder = true; this.RemainedIgnoreMouseButtonDownCount = Preference.Instance.DragClickNumberOfClicks; new Thread(() => { for (int i = 0; i < Preference.Instance.DragClickNumberOfClicks; i++) { GM.Instance.InputSimulator.Mouse.RightButtonClick(); Thread.Sleep(Preference.Instance.DragClickClickTimeIntervalMsec); } }).Start(); } }
public void PauseRecording() { ALog.Debug(""); this.State = ESRState.RecordingPause; this.WaitingRecorder.Stop(); OnStopRecording(); }
public void StartRecordingWithConfirm() { ALog.Debug(""); bool isReset = true; if (this.Items.Count > 0) { MessageBoxResult result = MessageBox.Show("Do you want to reset all of recorder items?", "Question", MessageBoxButton.YesNoCancel, MessageBoxImage.Question); if (result == MessageBoxResult.Cancel) { return; } if (result == MessageBoxResult.Yes) { isReset = true; } else if (result == MessageBoxResult.No) { isReset = false; } } if (isReset) { this.Reset(); } StartRecording(); }
public bool Start() { if (this.IsThreadEnable) { return(false); } this.CancelToken = new CancellationTokenSource(); ThreadPool.QueueUserWorkItem(new WaitCallback((obj) => { CancellationToken token = (CancellationToken)obj; this.IsThreadEnable = true; const double waitTime = 0.02f; // 20 mesc while (!token.IsCancellationRequested) { double startTime = Stopwatch.GetTimestamp(); if (this.CurrentWaitingTimeSec >= this.WaitingTimeSec) { AddWaitingRecorderItem(this.CurrentWaitingTimeSec); } Thread.Sleep((int)(waitTime * 1000)); this.CurrentWaitingTimeSec += (((double)Stopwatch.GetTimestamp() - startTime) / (double)Stopwatch.Frequency); } AddWaitingRecorderItem(this.CurrentWaitingTimeSec); }), this.CancelToken.Token); ALog.Debug("Start WaitingRecorder ThreadPool"); return(true); }
private bool IsContinuePlaying() { ALog.Debug(""); if (Preference.Instance.RepeatType == RepeatType.Infinite) { return(true); } if (Preference.Instance.RepeatType == RepeatType.Count) { bool isContinue = true; Preference.Instance.MainWindow.InvokeIfRequired(() => { if (Preference.Instance.RepeatCountControl.Value <= 0) { isContinue = false; } Preference.Instance.RepeatCountControl.Value--; }); return(isContinue); } return(false); }
public void ResetItems() { ALog.Debug(""); this.StopPlaying(); this.StopRecording(); this.Reset(); }
private void OnPushKey(VirtualKeyCode key) { ALog.Debug("VirtualKeyCode={0}", key.ToString()); if (key == VirtualKeyCode.DELETE && AUtil.IsStop(this.Recorder.State)) { DeleteKey(); } }
public bool Start(List <IRecorderItem> items) { if (items.Count <= 0) { ALog.Debug("Playing item is 0."); return(false); } Stop(); ResetLastItem(); this.CancelToken = new CancellationTokenSource(); ThreadPool.QueueUserWorkItem(new WaitCallback((obj) => { CancellationToken token = (CancellationToken)obj; this.IsThreadEnable = true; bool isLastStep = false; if (OnStartPlaying != null) { OnStartPlaying(); } this.CurrentRecorder = items.First(); while (!token.IsCancellationRequested) { if (!this.CurrentRecorder.Play(this)) { break; } if (IsLastStep(items)) { if (IsContinuePlaying()) { this.CurrentRecorder = items.First(); continue; } isLastStep = true; break; } if (!NextStep(items)) { break; } } if (OnStopPlaying != null) { OnStopPlaying(isLastStep); } }), this.CancelToken.Token); ALog.Debug("Start Playing ThreadPool"); return(true); }
public void StartPlaying(bool isReset) { ALog.Debug("IsReset={0}", isReset); if (isReset) { ResetToStart(); } StartPlaying(); }
public void ResetToStart() { ALog.Debug(""); if (!AUtil.IsStopPause(this.State)) { return; } this.Player.ResetToStart(); }
public void Initialize(ESRRecorder recorder) { ALog.Debug(""); this.Recorder = recorder; this.Recorder.OnChangedState += (state) => { this.InvokeIfRequired(() => { EnableToolbarButton(state); }); }; }
private void OnRecording() { ALog.Debug("State={0}", this.Recorder.State); if (AUtil.IsStopPause(this.Recorder.State)) { bool isReset = this.Recorder.State != ESRState.RecordingPause; this.Recorder.StartRecording(); } else { this.Recorder.PauseAll(); } }
public bool StartPlaying(List <IRecorderItem> items) { if (items.Count <= 0) { ALog.Debug("ESRRecorder::StartPlaying::Item's count is 0."); return(false); } ALog.Debug(""); this.State = ESRState.Playing; this.Player.Start(items); return(true); }
private void AddWaitingRecorderItem(double waitingTimeSec) { IRecorderItem newRecorder = null; newRecorder = new WaitTimeRecorderItem() { WaitingTimeSec = waitingTimeSec, }; if (this.CurrentRecorder?.IsEqualType(newRecorder) == true) { this.CurrentRecorder.ChildItems.Add(newRecorder); this.ESRRecorder.UpdateItem(this.CurrentRecorder); return; } this.ESRRecorder.AddItem(newRecorder); ALog.Debug("Add Waiting Event!"); }
public bool ReplaceItem(IRecorderItem oldItem, IRecorderItem newItem) { int index = this.Items.IndexOf(oldItem); if (index < 0 || index >= this.Items.Count) { ALog.Debug("ReplaceItem::Index is invalide!(Index={0})", index); return(false); } ResetWaitingTime(); this.CurrentRecorder = newItem; this.Items[index] = newItem; if (OnReplaceItem != null) { OnReplaceItem(oldItem, newItem); } return(true); }
private bool NextStep(List <IRecorderItem> items) { int index = items.IndexOf(this.CurrentRecorder); if (index == -1) { ALog.Debug("ESRPlayer::index not found."); return(false); } if (index >= items.Count - 1) { ALog.Debug("ESRPlayer::Current index is last index"); return(false); } index++; ALog.Debug($"ESRPlayer::Current index is {index}"); this.CurrentRecorder = items[index]; return(true); }
public void StopPlaying() { ALog.Debug(""); this.Player.Stop(); this.State = ESRState.Stop; }
public void StopDragClick() { ALog.Debug(""); this.State = ESRState.Stop; OnStopRecording(); }
public void Initialize(ESRRecorder recorder) { ALog.Debug(""); this.Recorder = recorder; }
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); }
public void PausePlaying() { ALog.Debug(""); this.Player.Stop(); this.State = ESRState.PlayingPause; }
private void OnDragClickStart() { ALog.Debug("OnDragClickStart={0}", this.Recorder.State); this.Recorder.StartDragClick(); }
public void Add(MouseEventArgs e) { IRecorderItem newRecorder = null; if (e.Message == MouseMessages.WM_MOUSEWHEEL) { newRecorder = new MouseWheelRecorderItem() { Dir = ((int)e.MouseData) > 0 ? Dir.Up : Dir.Down, Point = new System.Windows.Point(e.Point.x, e.Point.y), MouseData = (int)e.MouseData, }; if (IsCurrentMouseWheelDir(newRecorder)) { this.WaitingRecorder.ResetWaitingTime(); this.CurrentRecorder.ChildItems.Add(newRecorder); this.ESRRecorder.UpdateItem(this.CurrentRecorder); return; } } else if (e.Message == MouseMessages.WM_LBUTTONDOWN || e.Message == MouseMessages.WM_RBUTTONDOWN || e.Message == MouseMessages.WM_WHEELBUTTONDOWN) { if (IsLastMouseDown()) { return; } if (IsMouseButtonPress()) { newRecorder = new MouseClickRecorderItem() { Button = ToButtonType(e.Message), Point = new System.Windows.Point(e.Point.x, e.Point.y), MouseData = (int)e.MouseData, }; this.ESRRecorder.ResetWaitingTime(); this.CurrentMouseRecorder.ChildItems.Add(newRecorder); this.ESRRecorder.UpdateItem(this.CurrentMouseRecorder); return; } newRecorder = new MouseUpDownRecorderItem() { Dir = Dir.Down, Button = ToButtonType(e.Message), Point = new System.Windows.Point(e.Point.x, e.Point.y), MouseData = (int)e.MouseData, }; } else if (e.Message == MouseMessages.WM_LBUTTONUP || e.Message == MouseMessages.WM_RBUTTONUP || e.Message == MouseMessages.WM_WHEELBUTTONUP) { if (IsMouseButtonPress()) { ALog.Debug("MouseEvent.Up, IsMouseButtonPress: True"); if (IsCurrentMouseClick()) { return; } //Remove MouseDown item this.ESRRecorder.DeleteItem(this.CurrentMouseRecorder); this.ESRRecorder.ResetCurrentRecorderbyLast(); newRecorder = new MouseClickRecorderItem() { Button = ToButtonType(e.Message), Point = new System.Windows.Point(e.Point.x, e.Point.y), MouseData = (int)e.MouseData, }; } else { newRecorder = new MouseUpDownRecorderItem() { Dir = Dir.Up, Button = ToButtonType(e.Message), Point = new System.Windows.Point(e.Point.x, e.Point.y), MouseData = (int)e.MouseData, }; } } else if (e.Message == MouseMessages.WM_MOUSEMOVE) { newRecorder = new MouseMoveRecorderItem() { Point = new System.Windows.Point(e.Point.x, e.Point.y), MouseData = (int)e.MouseData, }; if (IsIgnoreMouseMove(newRecorder)) { ALog.Debug("ESRMouseRecorder::Add(MouseEvent)::IsIgnoreMouseMove"); return; } if (IsCurrentMouseMove()) { this.WaitingRecorder.ResetWaitingTime(); this.CurrentMouseRecorder.ChildItems.Add(newRecorder); this.ESRRecorder.UpdateItem(this.CurrentMouseRecorder); return; } } //Need to delete Unnecessary a mouse move item if (IsCurrentSingleMouseMove(newRecorder)) { this.ESRRecorder.DeleteItem(this.CurrentRecorder); } this.ESRRecorder.AddMouseItem(newRecorder); }
private void OnStop() { ALog.Debug("State={0}", this.Recorder.State); this.Recorder.PauseAll(); }
private void buttonRecord_Click(object sender, RoutedEventArgs e) { ALog.Debug(""); this.Recorder.StartRecordingWithConfirm(); }
private void buttonStop_Click(object sender, RoutedEventArgs e) { ALog.Debug(""); this.Recorder.StopAll(); }
public void StopAll() { ALog.Debug(""); this.StopRecording(); this.StopPlaying(); }
public bool SaveFile() { //Header Array.Clear(this.FileHeaderRaw, 0, this.FileHeaderRaw.Length); string header = null; try { header = this.FileHeader.ToJsonString(); } catch (Exception ex) { ALog.Debug($"ESRFile SaveFile Error - Header! ({ex.Message})"); return(false); } byte[] headerArray; headerArray = Encoding.UTF8.GetBytes(header); Array.Copy(headerArray, this.FileHeaderRaw, headerArray.Length); //Body byte[] bodyArray; try { bodyArray = Encoding.UTF8.GetBytes(this.FileBody.ToJsonString()); } catch (Exception ex) { ALog.Debug($"ESRFile SaveFile Error - Body! ({ex.Message})"); return(false); } //FileStream try { //If already the file is exist, first delete it. if (File.Exists(this.FileName)) { File.Delete(this.FileName); } using (FileStream fs = File.Open(this.FileName, FileMode.CreateNew)) { //ESR File Keyword fs.Write(Encoding.ASCII.GetBytes(ESRFileHeader.ESRFileKeyword), 0, ESRFileHeader.ESRFileKeyword.Length); //Header fs.Write(this.FileHeaderRaw, 0, this.FileHeaderRaw.Length); //Body fs.Write(bodyArray, 0, bodyArray.Length); } } catch (Exception ex) { ALog.Debug($"ESRFile SaveFile Error - FileSteram! ({ex.Message})"); return(false); } return(true); }
public void StartDragClick() { ALog.Debug(""); this.State = ESRState.DragClick; this.WaitingRecorder.Stop(); }