private void WorkClick(object state) { this.context.Send(new SendOrPostCallback(delegate(object _state) { Konum konum = state as Konum; SetCursorPos(konum.X, konum.Y); Thread.Sleep(100); mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0); mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, 0); }), state); }
private void Form1_KeyPress(object sender, KeyPressEventArgs e) { if (e.KeyChar.Equals('c')) { end = DateTime.Now; if (first) { start = end; first = false; } int x = Cursor.Position.X; int y = Cursor.Position.Y; TimeSpan ts = end - start; double sec = 0; if (nWait.Value.Equals(0)) { sec = ts.TotalSeconds; sec = Math.Round(sec, 1); } else { sec = (double)nWait.Value; } start = end; string point = x.ToString() + "," + y.ToString(); ListViewItem lsti = new ListViewItem(new string[] { point, "0", no.ToString() }); no = no + 1; Konum konum = new Konum(x, y, 0); lsti.Tag = konum; lstBilgi.Items.Add(lsti); int index = lstBilgi.Items.Count; if (index > 1) { lstBilgi.Items[index - 1].SubItems[1].Text = sec.ToString(); (lstBilgi.Items[index - 1].Tag as Konum).Aralik = (int)sec; } } if (e.KeyChar.Equals('S')) { btnStart.PerformClick(); } else if (e.KeyChar.Equals((char)Keys.Escape))//Esc { btnCancel.PerformClick(); this.Focus(); } }