Exemple #1
0
        private void do_mywork()
        {
            lvActions.Items.Clear();
            ClickType ct  = ClickType.click;
            int       x   = this.DesktopLocation.X + 16; //Cursor.Position.X;
            int       y   = this.DesktopLocation.Y + 8;  //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();

            string       text  = ct.Equals(ClickType.SendKeys) ? txbEntry.Text : string.Empty;
            ListViewItem lvi   = new ListViewItem(new string[] { point, ct.ToString(), "0", text });
            ActionEntry  acion = new ActionEntry(x, y, text, 0, ct);

            lvi.Tag = acion;
            lvActions.Items.Add(lvi);
            int index = lvActions.Items.Count;

            if (index > 1)
            {
                lvActions.Items[index - 2].SubItems[2].Text = sec.ToString();
                (lvActions.Items[index - 2].Tag as ActionEntry).Interval = (int)sec;
            }

            toolStripStatusLabel1.Text = string.Format("Position: {0} ,{1}", x.ToString(), y.ToString());
            Application.DoEvents();

            enableButtons(false);

            if (runActionThread == null || !runActionThread.IsAlive)
            {
                actions.Clear();
                foreach (ListViewItem lvii in lvActions.Items)
                {
                    actions.Add(lvii.Tag as ActionEntry);
                }
                runActionThread = new Thread(RunAction);
                runActionThread.Start();
            }
        }
Exemple #2
0
        private void Form1_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (byTextEntry)
            {
                return;
            }

            if (e.KeyChar.Equals('c') || e.KeyChar.Equals('d') ||
                e.KeyChar.Equals('r') || e.KeyChar.Equals('t'))
            {
                end = DateTime.Now;
                if (first)
                {
                    start = end;
                    first = false;
                }

                ClickType ct = ClickType.click;
                if (e.KeyChar.Equals('c'))
                {
                    //cl = ClickType.click;
                }
                else if (e.KeyChar.Equals('d'))
                {
                    ct = ClickType.doubleClick;
                }
                else if (e.KeyChar.Equals('r'))
                {
                    ct = ClickType.rightClick;
                }
                else //if (e.KeyChar.Equals('t'))
                {
                    ct = ClickType.SendKeys;
                }

                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();

                string       text  = ct.Equals(ClickType.SendKeys) ? txbEntry.Text : string.Empty;
                ListViewItem lvi   = new ListViewItem(new string[] { point, ct.ToString(), "0", text });
                ActionEntry  acion = new ActionEntry(x, y, text, 0, ct);
                lvi.Tag = acion;
                lvActions.Items.Add(lvi);
                int index = lvActions.Items.Count;
                if (index > 1)
                {
                    lvActions.Items[index - 2].SubItems[2].Text = sec.ToString();
                    (lvActions.Items[index - 2].Tag as ActionEntry).Interval = (int)sec;
                }
            }
            if (e.KeyChar.Equals('S'))
            {
                btnStart.PerformClick();
            }
            else if (e.KeyChar.Equals((char)Keys.Escape))//Esc
            {
                btnCancel.PerformClick();
                this.Focus();
            }
        }