void ReplayThread() { var inputs = from x in this.keys select x.ToInput(); Stopwatch sw = new Stopwatch(); sw.Start(); foreach (var input in inputs) { while (input.ki.time > sw.ElapsedMilliseconds) { Thread.Sleep(1); //this.Dispatch(() => { this.labelDebug.Content = string.Format("{0} : {1}", input.ki.time, sw.ElapsedMilliseconds); }); } Win32.SendInput(input); if (!this.isReplayAlive) { break; } } sw.Stop(); this.Dispatch(() => { this.buttonReplay.IsEnabled = true; this.replay = null; this.isReplayAlive = false; }); }
void ReplayThread() { var inputs = from x in this.keys select new INPUT { type = type.INPUT_KEYBOARD, ki = new KEYBDINPUT { time = (int)x.Elapsed, wVk = (wVk)x.Code, dwFlags = x.Type == EventType.KeyDown ? dwFlags.KEYEVENTF_KEYDOWN : dwFlags.KEYEVENTF_KEYUP, }, }; Stopwatch sw = new Stopwatch(); sw.Start(); foreach (var input in inputs) { while (input.ki.time > sw.ElapsedMilliseconds) { Thread.Sleep(1); //this.Dispatch(() => { this.labelDebug.Content = string.Format("{0} : {1}", input.ki.time, sw.ElapsedMilliseconds); }); } Win32.SendInput(input); if (!this.isReplayAlive) { break; } } sw.Stop(); this.Dispatch(() => { this.buttonReplay.IsEnabled = true; this.replay = null; this.isReplayAlive = false; }); }