void OnMouseDown(object sender, MouseEventExtArgs e) { m_GlobalHook.MouseDownExt -= OnMouseDown; //It is recommened to dispose it m_GlobalHook.Dispose(); counter++; KeyCaptureRecord mouseRecord = new KeyCaptureRecord() { DurationSeconds = stopWatch.ElapsedMilliseconds / 1000, X = e.X, Y = e.Y }; this.records.Add(mouseRecord); }
void t_Elapsed(object sender, ElapsedEventArgs e) { tick++; if (tick > this.record.MaxSecond) { tick = 0; System.Diagnostics.Debug.Print("timer stopped.."); } KeyCaptureRecord r = this.record.Items.Where(p => p.DurationSeconds == tick).FirstOrDefault(); if (r == null) { return; } MouseOperations.SetCursorPosition(r.X, r.Y); MouseOperations.MouseEvent(MouseOperations.MouseEventFlags.LeftDown); MouseOperations.MouseEvent(MouseOperations.MouseEventFlags.LeftUp); }
public IRecord LoadRecord(string fileName) { IRecord rec = null; List <KeyCaptureRecord> records = new List <KeyCaptureRecord>(); string recordedFile = Path.Combine(Path.GetTempPath(), fileName); if (File.Exists(recordedFile)) { using (StreamReader reader = new StreamReader(recordedFile)) { while (!reader.EndOfStream) { string line = reader.ReadLine(); string[] splits = line.Split(','); KeyCaptureRecord r = new KeyCaptureRecord(); r.X = int.Parse(splits[0]); r.Y = int.Parse(splits[1]); r.DurationSeconds = int.Parse(splits[2]); records.Add(r); } if (records.Count > 0) { rec = new Record(records); } } //maxTick = this.records.Select(p => p.DurationSeconds).Max(); } return(rec); }