Example #1
0
        public static void SendKey(int keyCode, Setting setting)
        {
            if (keyCode == (int)Keys.NumPad1)
            {
                for (var i = 1; i <= 2; i++)
                {
                    SendKeys.SendWait(i.ToString());
                    SendKeys.Flush();
                    Clicker.LeftClick(Cursor.Position.X, Cursor.Position.Y, setting.CompressDelay);
                    SendKeys.Flush();
                }
            }

            if (keyCode == (int)Keys.Add)
            {
                Clicker.RightClick(30);
                var temp = Cursor.Position;
                int x    = 50;
                SendKeys.Send("2");
                Thread.Sleep(20);
                Clicker.LeftClick(180, 705, setting.DelayS);
                Thread.Sleep(x + 30);
                SendKeys.Send("1");
                Thread.Sleep(20);
                Clicker.LeftClick(180, 705, setting.DelayS);
                Thread.Sleep(x + 20);
                MouseOperations.SetCursorPosition(temp.X, temp.Y);
                Thread.Sleep(x + 10);
                Clicker.RightClick(20);
            }

            if (keyCode == (int)Keys.NumPad5)
            {
                ShortcutManager.CtrlWith(Keys.N, setting.DelayS);
            }

            if (keyCode == (int)Keys.N)
            {
                ShortcutManager.CtrlWith(Keys.N, setting.DelayS);
            }

            if (keyCode == (int)Keys.G)
            {
                ShortcutManager.CtrlWith(Keys.G, setting.DelayS);
            }

            if (keyCode == (int)Keys.M)
            {
                ShortcutManager.CtrlWith(Keys.M, setting.DelayS);
            }

            if (keyCode == (int)Keys.H)
            {
                ShortcutManager.CtrlWith(Keys.H, setting.DelayS);
            }

            if (keyCode == (int)Keys.B)
            {
                ShortcutManager.CtrlWith(Keys.B, setting.DelayS);
            }

            if (keyCode == (int)Keys.I)
            {
                ShortcutManager.CtrlWith(Keys.I, setting.DelayS);
            }

            if (keyCode == (int)Keys.E)
            {
                var pos = Cursor.Position;
                Clicker.LeftClick(pos.X, pos.Y, setting.DelayS);
                Clicker.LeftClick(586, 707, setting.DelayS);
                MouseOperations.SetCursorPosition(pos.X, pos.Y);
            }

            if (keyCode == (int)Keys.S)
            {
                MoveDirection.Direction(Keys.Down, setting.Direction);
            }

            if (keyCode == (int)Keys.W)
            {
                MoveDirection.Direction(Keys.Up, setting.Direction);
            }

            if (keyCode == (int)Keys.A)
            {
                MoveDirection.Direction(Keys.Left, setting.Direction);
            }

            if (keyCode == (int)Keys.D)
            {
                MoveDirection.Direction(Keys.Right, setting.Direction);
            }

            if (keyCode == (int)Keys.Q)
            {
                var corner = new List <Point>()
                {
                    new Point(159, 732),
                    new Point(192, 730),
                    new Point(162, 760),
                    new Point(192, 759),
                };
                var p = Pip.PointInPolygan(corner).FirstOrDefault();

                var current = new Point(Cursor.Position.X, Cursor.Position.Y);

                Clicker.LeftClick(10);
                MouseMoves.LinearSmoothMove(p, setting.MouseSpeed);
                Clicker.LeftClick(10);
                MouseMoves.LinearSmoothMove(current, setting.MouseSpeed);
            }



            //if (keyCode == (int)Keys.W)
            //{
            //    var p1 = Cursor.Position;
            //    int dddd = 100;
            //    Clicker.LeftClick(p1.X, p1.Y, delayNumber + dddd);
            //    Clicker.LeftClick((p1.X - 63), (p1.Y - 33), delayNumber + dddd);
            //    Clicker.LeftClick((p1.X + 66), (p1.Y - 33), delayNumber + dddd);
            //    Clicker.LeftClick((p1.X), (p1.Y - 66), delayNumber + dddd);
            //}
        }
Example #2
0
        protected override void WndProc(ref Message xMessage)
        {
            var keyCode    = xMessage.WParam.ToInt32();
            var hotKeyInfo = HotKeyInfo.GetFromMessage(xMessage);

            if (hotKeyInfo != null)
            {
                if (hotKeyInfo.Modifiers == Modifiers.Alt && hotKeyInfo.Key == Keys.NumPad9)
                {
                    int?maxPikeSin = CalcMove.PikeSin.OrderBy(n => n).Cast <int?>()
                                     .FirstOrDefault(n => n >= 9);
                    if (maxPikeSin.HasValue)
                    {
                        CalcMove.PikeSin.Remove(maxPikeSin.Value);
                    }
                }

                if (keyCode == AddGroup.Id)
                {
                    int?maxPikeSin = CalcMove.PikeSin.OrderBy(n => n).Cast <int?>()
                                     .FirstOrDefault(n => n >= 9);
                    if (!maxPikeSin.HasValue)
                    {
                        CalcMove.PikeSin.Add(9);
                    }
                }

                if (keyCode == Rules.Id)
                {
                    var sim = new InputSimulator();
                    sim.Keyboard.Sleep(1000)
                    .TextEntry(Setting.Rules)
                    .Sleep(1000);
                }

                if (keyCode == StartRecordPattern.Id)
                {
                    Voice.PlaySound("//Voice//Start.wav");
                    FrmRecordShieldPattern = new FrmFormStatic();
                    FrmRecordShieldPattern.ShowDialog();
                }

                if (keyCode == EndRecordPattern.Id)
                {
                    var allPositionClick = HookManager.PositionClick;
                    var stringData       = JsonConvert.SerializeObject(allPositionClick);
                    var newPatternName   = Guid.NewGuid();
                    var newPattern       = PatternShieldAddress + newPatternName.ToString() + ".txt";
                    if (!File.Exists(newPattern))
                    {
                        var temp = File.Create(newPattern);
                        temp.Close();
                    }
                    File.AppendAllText(newPattern, stringData);
                    FrmRecordShieldPattern.DialogResult = DialogResult.OK;
                    Voice.PlaySound("//Voice//Ending.wav");
                }
            }

            if (keyCode == (int)Keys.S)
            {
                Key.SendKey(keyCode, Setting);
            }

            if (keyCode == (int)Keys.W)
            {
                Key.SendKey(keyCode, Setting);
            }

            if (keyCode == (int)Keys.A)
            {
                Key.SendKey(keyCode, Setting);
            }

            if (keyCode == (int)Keys.D)
            {
                Key.SendKey(keyCode, Setting);
            }

            if (keyCode == (int)Keys.Q)
            {
                Key.SendKey(keyCode, Setting);
            }



            if (keyCode == (int)Keys.F6)
            {
                var pattern = Directory.GetFiles(PatternShieldAddress).ToList();
                if (pattern.Count == 0)
                {
                    return;
                }
                var r = new Random();
                var choosePatternNumber = r.Next(0, pattern.Count - 1);
                var choosePattern       = pattern[choosePatternNumber];
                var readPattern         = File.ReadAllText(choosePattern);
                var containPattern      = JsonConvert.DeserializeObject <List <Point> >(readPattern);
                var c = Cursor.Position;
                foreach (Point point in containPattern)
                {
                    Clicker.LeftClick(20);
                    MouseMoves.LinearSmoothMove(point, Setting.MouseSpeed);
                    Clicker.LeftClick(20);
                }
            }

            if (keyCode == (int)Keys.Decimal)
            {
                foreach (var i in CalcMove.PikeSin.Distinct())
                {
                    Key.MoveOne(i, Setting.CompressDelay);
                }
            }

            if (keyCode == (int)Keys.NumPad2)
            {
                if (ControlMode == ControlMode.Kn)
                {
                    foreach (var i in CalcMove.Kn.Distinct())
                    {
                        if (i == 1 || i == 2)
                        {
                            continue;
                        }
                        Key.MoveOne(i, Setting.CompressDelay);
                    }
                }
            }

            if (keyCode == (int)Keys.Divide)
            {
                if (ControlMode == ControlMode.PikeSin)
                {
                    ControlMode = ControlMode.Kn;
                    btnKn.Text  = "KN";
                    Voice.PlaySound("//Voice//Knight_s6.wav");
                    CalcMove.SetKn(CalcMove.Kn);
                    CalcMove.Sort();
                }
                else
                {
                    ControlMode = ControlMode.PikeSin;
                    btnKn.Text  = "PikeSin";
                    Voice.PlaySound("//Voice//Knight_Disband1.wav");
                    CalcMove.SetPikeSin();
                }
            }

            if (keyCode == (int)Keys.Subtract)
            {
                if (ControlMode == ControlMode.PikeSin)
                {
                    CalcMove.SetPikeSin();
                }
                else
                {
                    if (CalcMove.Kn.Count != 0)
                    {
                        var bigger = CalcMove.Kn.Max();
                        CalcMove.Kn.Remove(bigger);
                        CalcMove.PikeSin.Add(bigger);
                    }
                }
                CalcMove.Sort();
            }

            if (keyCode == (int)Keys.Multiply)
            {
                if (CalcMove.PikeSin.Count != 0)
                {
                    CalcMove.PikeSin.Sort();
                    int smaller = 0;
                    if (CalcMove.PikeSin.Count == 1)
                    {
                        smaller = CalcMove.PikeSin.Min();
                    }
                    else
                    {
                        smaller = CalcMove.PikeSin.Skip(1).Min();
                    }
                    CalcMove.PikeSin.Remove(smaller);
                    CalcMove.Kn.Add(smaller);
                }
                CalcMove.Sort();
            }

            if (keyCode == (int)Keys.NumPad1)
            {
                Key.SendKey(keyCode, Setting);
            }

            if (keyCode == (int)Keys.Add)
            {
                Key.SendKey(keyCode, Setting);
            }

            if (keyCode == (int)Keys.NumPad5)
            {
                Key.SendKey(keyCode, Setting);
            }

            if (keyCode == (int)Keys.N)
            {
                Key.SendKey(keyCode, Setting);
            }

            if (keyCode == (int)Keys.G)
            {
                Key.SendKey(keyCode, Setting);
            }

            if (keyCode == (int)Keys.M)
            {
                Key.SendKey(keyCode, Setting);
            }

            if (keyCode == (int)Keys.H)
            {
                Key.SendKey(keyCode, Setting);
            }

            if (keyCode == (int)Keys.B)
            {
                Key.SendKey(keyCode, Setting);
            }

            if (keyCode == (int)Keys.I)
            {
                Key.SendKey(keyCode, Setting);
            }

            if (keyCode == (int)Keys.E)
            {
                Key.SendKey(keyCode, Setting);
            }

            if (keyCode == (int)Keys.NumPad3)
            {
                AssassinFlag.Move(Setting.FlagDelay);
            }

            if (keyCode == (int)Keys.Insert)
            {
                if (checkBox2.Checked == false)
                {
                    System.Media.SoundPlayer player = new System.Media.SoundPlayer(Environment.CurrentDirectory + "//Voice//Engineer_catplt1.wav");
                    player.Load();
                    player.Play();
                    this.BackColor = Color.CornflowerBlue;
                    RegisterKey();
                    btnActive.Text      = "Active ON (Insert)";
                    btnActive.ForeColor = Color.DodgerBlue;
                    checkBox2.Checked   = true;
                    return;
                }

                if (checkBox2.Checked)
                {
                    System.Media.SoundPlayer player = new System.Media.SoundPlayer(Environment.CurrentDirectory + "//Voice//AEngineer_Exit1.wav");
                    player.Load();
                    player.Play();
                    this.BackColor = Color.Coral;
                    UnRegisterKey();
                    btnActive.Text      = "Active OFF (Insert)";
                    btnActive.ForeColor = Color.Crimson;
                    checkBox2.Checked   = false;
                    return;
                }
            }

            if (keyCode == (int)Keys.F4)
            {
                var shieldPosition = new Point(Cursor.Position.X, Cursor.Position.Y);
                Clicker.LeftClick(130, 700, Setting.CompressDelay);
                Clicker.LeftClick(shieldPosition.X, shieldPosition.Y, Setting.CompressDelay);
            }

            if (keyCode == (int)Keys.F5)
            {
                var shieldPosition = new Point(Cursor.Position.X, Cursor.Position.Y);
                Clicker.LeftClick(173, 745, Setting.CompressDelay);
                Clicker.LeftClick(shieldPosition.X, shieldPosition.Y, Setting.CompressDelay);
            }

            if (keyCode == (int)Keys.End || keyCode == (int)Keys.PageDown)
            {
                //    var tc = new Random();
                //    var index = tc.Next(1, ValidPoint.Count - 1);
                //    MouseMoves.LinearSmoothMove(new Point(Cursor.Position.X, Cursor.Position.Y), int.Parse(textBox7.Text));
                //    MouseMoves.LinearSmoothMove(new Point(ValidPoint[index].X, ValidPoint[index].Y), int.Parse(textBox7.Text));
                //    Clicker.LeftClick(ValidPoint[index].X, ValidPoint[index].Y, Setting.CompressDelay);
            }

            base.WndProc(ref xMessage);
        }