Ejemplo n.º 1
0
        private void ExcuteControl(Config item)
        {
            if (item.state == Config.EState.Click)
            {
                new Thread(() =>
                {
                    DateTime objCurrentTime = new DateTime();
                    objCurrentTime          = DateTime.Now;

                    while (true)
                    {
                        var time = DateTime.Now - objCurrentTime;
                        if (item.delay < time.TotalMilliseconds)
                        {
                            break;
                        }
                        Thread.Sleep(10);
                    }
                    if (item.key == Keys.LButton || item.key == Keys.RButton || item.key == Keys.MButton || item.key == Keys.XButton1 || item.key == Keys.XButton2)
                    {
                        MouseClick(item.key, item.time);
                    }
                    else
                    {
                        KeyClick(item.key, item.time, item.bCtrl, item.bAlt, item.bShift);
                    }
                }).Start();
            }
            else if (item.state == Config.EState.NoneClick)
            {
                if (item.key == Keys.LButton || item.key == Keys.RButton || item.key == Keys.MButton || item.key == Keys.XButton1 || item.key == Keys.XButton2)
                {
                    new Thread(() =>
                    {
                        DateTime objCurrentTime = new DateTime();
                        objCurrentTime          = DateTime.Now;

                        while (true)
                        {
                            var time = DateTime.Now - objCurrentTime;
                            if (item.delay < time.TotalMilliseconds)
                            {
                                break;
                            }
                            Thread.Sleep(10);
                        }
                        mouseHook.AddNotInputKey(item.key, item.time);
                    }).Start();
                }
                else
                {
                    new Thread(() =>
                    {
                        DateTime objCurrentTime = new DateTime();
                        objCurrentTime          = DateTime.Now;

                        while (true)
                        {
                            var time = DateTime.Now - objCurrentTime;
                            if (item.delay < time.TotalMilliseconds)
                            {
                                break;
                            }
                            Thread.Sleep(10);
                        }
                        keyboardHook.AddNotInputKey(item.key, item.time);
                    }).Start();
                }
            }
            else if (item.state == Config.EState.MouseMove)
            {
                new Thread(() =>
                {
                    DateTime objCurrentTime = new DateTime();
                    objCurrentTime          = DateTime.Now;

                    while (true)
                    {
                        var time = DateTime.Now - objCurrentTime;
                        if (item.delay < time.TotalMilliseconds)
                        {
                            break;
                        }
                        Thread.Sleep(10);
                    }

                    objCurrentTime = DateTime.Now;

                    while (true)
                    {
                        var time = DateTime.Now - objCurrentTime;
                        if (item.time < time.TotalMilliseconds)
                        {
                            break;
                        }
                        if (item.moveDirection == Config.EMoveDirection.Left || item.moveDirection == Config.EMoveDirection.Right)
                        {
                            int x = MouseSimulator.X;
                            if (item.moveDirection == Config.EMoveDirection.Left)
                            {
                                MouseMove.ExecuteMove(-item.speed, 0);
                                x -= item.speed;
                            }
                            else
                            {
                                MouseMove.ExecuteMove(item.speed, 0);
                                x += item.speed;
                            }
                        }
                        else
                        {
                            int y = MouseSimulator.Y;
                            if (item.moveDirection == Config.EMoveDirection.Bottom)
                            {
                                MouseMove.ExecuteMove(0, item.speed);
                                y += item.speed;
                            }
                            else
                            {
                                MouseMove.ExecuteMove(0, -item.speed);
                                y -= item.speed;
                            }
                        }
                        Thread.Sleep(10);
                    }
                }).Start();
            }
            else if (item.state == Config.EState.AbsMouseMove)
            {
                new Thread(() =>
                {
                    DateTime objCurrentTime = new DateTime();
                    objCurrentTime          = DateTime.Now;

                    while (true)
                    {
                        var time = DateTime.Now - objCurrentTime;
                        if (item.delay < time.TotalMilliseconds)
                        {
                            break;
                        }
                        Thread.Sleep(10);
                    }
                    MouseSimulator.X = item.x;
                    MouseSimulator.Y = item.y;
                }).Start();
            }
        }