public override string ToString() { switch (Type) { case MacroActionType.Delay: return(string.Format("{0:00}:{1:00}:{2:0000}", Delay.Value.Minutes, Delay.Value.Seconds, Delay.Value.Milliseconds)); case MacroActionType.Key: return(SendInputManager.GetKeyDescription(Key.Value)); default: return(string.Empty); } }
public VKeyItem(VKey key) { m_key = key; m_desription = SendInputManager.GetKeyDescription(key); }
private void bwMacro_DoWork(object sender, DoWorkEventArgs e) { foreach (MacroAction action in m_macro.Actions) { if (bwMacro.CancellationPending) { break; } else { bool reportedWaiting = false; while (!bwMacro.CancellationPending && WinAPI.GetForegroundWindow() != m_processManager.WindowHandle) { if (!reportedWaiting) { bwMacro.ReportProgress(0, "Waiting.."); reportedWaiting = true; } Thread.Sleep(10); } if (!bwMacro.CancellationPending) { switch (action.Type) { case MacroActionType.Delay: bwMacro.ReportProgress(0, "Delay"); int milisecondsToWait = (int)action.Delay.Value.TotalMilliseconds; DateTime startDelayTime = DateTime.Now; while (milisecondsToWait > (int)DateTime.Now.Subtract(startDelayTime).TotalMilliseconds) { if (bwMacro.CancellationPending) { break; } else { Thread.Sleep(10); } } break; case MacroActionType.Key: bwMacro.ReportProgress(0, "Key: " + SendInputManager.GetKeyDescription(action.Key.Value)); SendInputManager.SendInput(action.Key.Value); break; } } } } if (bwMacro.CancellationPending) { e.Cancel = true; } }