private void MouseClicked(Point pt) { ClickPattern.AddPoint(pt.x, pt.y, Int32.Parse(Internal_interval.Text)); MessageWindow.Items.Add("Added point (" + pt.x + ", " + pt.y + ")"); MouseInterceptor.OnClick -= MouseClicked; this.WindowState = FormWindowState.Normal; this.Activate(); }
private void AddPoint_Click(object sender, EventArgs e) { if (Xpos.Text == "" && Ypos.Text == "") { this.WindowState = FormWindowState.Minimized; MouseInterceptor.OnClick += MouseClicked; } else if (Xpos.Text == "" || Ypos.Text == "") { ToolTip tip = new ToolTip(); tip.IsBalloon = true; tip.InitialDelay = 0; tip.ShowAlways = true; tip.Show("Need two numbers!", this.Xpos, 2000); } else { ClickPattern.AddPoint(Int32.Parse(Xpos.Text), Int32.Parse(Ypos.Text), Int32.Parse(Internal_interval.Text)); MessageWindow.Items.Add("Point added (" + Xpos.Text + ", " + Ypos.Text + ")"); } }
public void Start() { MessageWindow.Items.Add("Pattern clicking started"); //Console.WriteLine("Pattern started"); Button_start.Enabled = false; int interval = Int32.Parse(Interval_h.Text) * 60 * 60 * 1000 + Int32.Parse(Interval_m.Text) * 60 * 1000 + Int32.Parse(Interval_s.Text) * 1000 + Int32.Parse(Interval_ms.Text); int delay = Int32.Parse(Delay_h.Text) * 60 * 60 * 1000 + Int32.Parse(Delay_m.Text) * 60 * 1000 + Int32.Parse(Delay_s.Text) * 1000; ClickPattern.Period = interval; // Console.WriteLine(delay + " miliseconds"); CancellationTokenSource source = new CancellationTokenSource(); CancellationToken token = source.Token; KeyboardInterceptor.OnClick += (key => { if (key == 117) { Console.WriteLine("Process stopped during initial delay"); source.Cancel(); } }); try { Task.Delay(delay).ContinueWith(x => { if (RepeatCheck.Checked) { Console.WriteLine("Unlimited clicking started"); ClickPattern.Click(); } else { Console.WriteLine("Limited clicking started"); ClickPattern.Click(Decimal.ToInt32(Repeat_count.Value)); } }, token).Wait(); } catch (AggregateException ae) { foreach (Exception e in ae.InnerExceptions) { if (e is TaskCanceledException) { Console.WriteLine("Clicking canceled during initial delay: {0}", ((TaskCanceledException)e).Message); } else { Console.WriteLine("Exception: " + e.GetType().Name); } } } finally { Button_start.Enabled = true; Button_stop.Enabled = false; source.Dispose(); this.WindowState = FormWindowState.Normal; this.Activate(); } }