Example #1
0
        private void timer_Tick(object sender, EventArgs e)
        {
            timer.Stop();
            if (!running)
            {
                return;
            }

            listView.Items[actionIndex].Selected = true;

            if (currentAction.Type == ActionType.Mouse)
            {
                var act = (MouseActionItem)currentAction;
                MouseCircleVisible v = act.Hide == MouseActionItem.BoolEnum.No
                                           ? MouseCircleVisible.Show
                                           : MouseCircleVisible.Hide;
                if (act.Location.HasValue)
                {
                    MouseHelper.AutoClick(act.Location.Value.X, act.Location.Value.Y, v);
                }
                else
                {
                    MouseHelper.AutoClick(v);
                }
            }
            else if (currentAction.Type == ActionType.Keyboard)
            {
                var act = (KeyboardActionItem)currentAction;
                if (!string.IsNullOrEmpty(act.Characters))
                {
                    foreach (char c in act.Characters)
                    {
                        KeyboardHelper.AutoInput(c);
                        Thread.Sleep(100);
                    }
                }
            }

            if (repeatTimes < currentAction.RepeatTime)
            {
                repeatTimes++;
                timer.Interval = currentAction.Interval;
                timer.Start();
            }
            else
            {
                repeatTimes    = 1;
                timer.Interval = currentAction.Wait;
                setNextAction();
                timer.Start();
            }
        }