예제 #1
0
        // 尋找購買書籤
        private void step_find_bookmark()
        {
            Thread.Sleep(1000);
            object X = 0;
            object Y = 0;

            dm.FindPic(0, 0, 960, 540, "bookmarkText.bmp", "444444", 0.7, 0, out X, out Y);

            if ((int)X < 0 || (int)Y < 0)
            {
                dm.FindPic(0, 0, 960, 540, "bookmarkText2.bmp", "444444", 0.7, 0, out X, out Y);
            }

            int x = (int)X;
            int y = (int)Y;

            //MessageBox.Show(x.ToString() + "," + y.ToString());
            if (x >= 0 && y >= 0)
            {
                dm.MoveTo(x + 380, y + 40);
                dm.LeftClick();
                Thread.Sleep(1000);
                dm.MoveTo(550, 375);
                dm.LeftClick();
                bookmark++;
                lb_bookmark.Text = bookmark.ToString();
            }
        }
예제 #2
0
        public int MoveTo(int x, int y)
        {
            switch (WindowsFormsApplication1.BaseData.SystemInfo.BindWindowsType)
            {
            case 1:    //1是大漠2是AE
            {
                return(dm.MoveTo(x, y));
            }

            case 2:
            {
                return(dm.MoveTo(x, y));
            }

            default:
                return(0);
            }
        }
예제 #3
0
        public static bool Init()
        {
            try
            {
                DM       = new CDmSoft();
                KeyInput = ((int vk, KeyFlag flag) => {
                    switch (flag)
                    {
                    case KeyFlag.Down: DM.KeyDown(vk); break;

                    case KeyFlag.Up: DM.KeyUp(vk); break;

                    case KeyFlag.Press: DM.KeyPress(vk); break;
                    }
                });
                MouseInput = ((int x, int y, MouseFlag flag, int data) => {
                    switch (flag)
                    {
                    case MouseFlag.MoveTo: DM.MoveTo(x, y); break;

                    case MouseFlag.AddTo: DM.MoveR(x, y); break;

                    case MouseFlag.Wheel:
                        if (data > 0)
                        {
                            DM.WheelUp();
                        }
                        else
                        {
                            DM.WheelDown();
                        }
                        break;

                    case MouseFlag.LeftDown: DM.LeftDown(); break;

                    case MouseFlag.LeftUp: DM.LeftUp(); break;

                    case MouseFlag.RightDown: DM.RightDown(); break;

                    case MouseFlag.RightUp: DM.RightUp(); break;
                    }
                });
            }
            catch
            {
                KeyInput   = KeyEvent.KeySend;
                MouseInput = KeyEvent.MouseSend;
                return(false);
            }
            return(true);
        }
예제 #4
0
        //Click
        private void ClickScreen(int RectWidth, int left, int top, int centerleft, int centertop, List <ClickEvent> clickEventList)
        {
            foreach (var clickEvent in clickEventList)
            {
                int clickPointX = 20 + clickEvent.LocalX * 16;
                int clickPointY = 63 + clickEvent.LocalY * 16;

                dm.MoveTo(clickPointX, clickPointY);


                if (clickEvent.ClickType == ClickType.LeftClick)
                {
                    dm.LeftClick();
                }
                else
                {
                    dm.RightClick();
                }
            }
        }
예제 #5
0
        public void button1_Click(object sender, EventArgs e)
        {
            int handle = gethandle();

            dm.ForceUnBindWindow(handle);

            dm.BindWindowEx(handle, "gdi", "windows", "windows", "", 0);
            // MessageBox.Show(handle.ToString());
            // dm.SetMouseDelay("windows", 180);
            // Đọc hình ảnh thành tọa độ , có 9 dòng và 16 cột , Ta cho thêm rìa ngoài 1  cột để tìm đường đi thành 11 dòng và 18 cột
            // ví dụ rắn ở tọa đô 1 1 , vậy là tọa dộ [1,1]  = 1 ( ta gán ở func dưới ) quét 1 lượt
            int[,] toado = new int[18, 11];
            do
            {
                for (int x = 0; x <= 17; x++)
                {
                    for (int y = 0; y <= 10; y++)
                    {
                        // toa do ngoài thì giá trị = 0 khỏi quét
                        if (x == 0 || y == 0 || x == 17 || y == 10)
                        {
                            toado[x, y] = 0;
                        }
                        else
                        {
                            //quét tọa độ của pikachu
                            toado[x, y] = findpikachu(x, y);
                        }
                    }
                }
                int[] arrayx = new int[18];
                int[] arrayy = new int[11];

                int count = 0;


                for (int z = 1; z <= 36; z++)
                {
                    for (int i = 1; i <= 16; i++)
                    {
                        for (int j = 1; j <= 9; j++)
                        {
                            if (toado[i, j] == z)
                            {
                                //gán tọa độ vào arrayx và y
                                arrayx[count] = i;
                                arrayy[count] = j;

                                count++;
                                if (count >= 4)
                                {
                                    count = 0;
                                }
                            }
                        }
                    }

                    //check có bị dính click ko


                    // sau khi gán ta có 2 hoặc 4 array , ta cho vào vòng lập check link và click lần lượt với nhau
                    bool isbool = true;
                    while (isbool)
                    {
                        isbool = false;
                        for (int i = 0; i <= 2; i++)
                        {
                            for (int j = i + 1; j <= 3; j++)
                            {
                                if (CheckLink(toado, arrayx[i], arrayy[i], arrayx[j], arrayy[j]) == true)
                                {
                                    //tìm toàn màn hình có bị dính màu đo đỏ khi lần trước click còn lưu lại, có thì click vào con đó
                                    dm.FindMultiColor(0, 0, 960, 540, "d24d57", "6|5|d24d57", 1, 0, out object x, out object y);
                                    int intX = Convert.ToInt32(x);
                                    int intY = Convert.ToInt32(y);
                                    if (intX != -1)
                                    {
                                        dm.MoveTo(intX, intY);
                                        dm.LeftClick();
                                    }
                                    Thread.Sleep(500);
                                    //ghi tọa độ ra để dễ nhìn
                                    Console.WriteLine((arrayx[i] + " " + arrayy[i] + " ," + arrayx[j] + " " + arrayy[j]));
                                    // move chuột lại và click vào tọa độ pikachu
                                    dm.MoveTo(43 + 55 * (arrayx[i] - 1), 68 + 55 * (arrayy[i] - 1));

                                    dm.LeftClick();
                                    Thread.Sleep(300);
                                    //do mình hay bị không click được con đầu nên mình làm thêm cái check có click được không, không được thì click tiếp .
                                    dm.FindMultiColor(0, 0, 960, 540, "d24d57", "6|5|d24d57", 1, 0, out x, out y);
                                    intX = Convert.ToInt32(x);
                                    intY = Convert.ToInt32(y);
                                    if (intX == -1)
                                    {
                                        dm.MoveTo(43 + 55 * (arrayx[i] - 1), 68 + 55 * (arrayy[i] - 1));

                                        dm.LeftClick();
                                    }

                                    Thread.Sleep(500);
                                    //move và click con thứ 2
                                    dm.MoveTo(43 + 55 * (arrayx[j] - 1), 68 + 55 * (arrayy[j] - 1));
                                    dm.delay(50);
                                    dm.LeftClick();

                                    Thread.Sleep(1000);
                                    // xóa phần từ để không check lại .
                                    Array.Clear(arrayx, i, j);
                                    Array.Clear(arrayy, i, j);
                                    isbool = true;
                                    break;
                                }
                            }
                        }
                    }



                    Thread.Sleep(10);
                    Array.Clear(arrayx, 0, arrayx.Length);
                    Array.Clear(arrayy, 0, arrayy.Length);
                }
            } while (true);
        }
예제 #6
0
        protected override void Process()
        {
            var screenX          = Screen.PrimaryScreen.WorkingArea.Width;
            var screenY          = Screen.PrimaryScreen.WorkingArea.Height;
            var fishRodShowDelay = 2000;
            var throwFishRodKey  = Keys.OemMinus;
            var addBaitKey       = Keys.Oemplus;
            var waterKey         = Keys.OemQuestion;
            var installRod       = Keys.OemBackslash;
            var waterHits        = 10;
            var itemKeyList      = new List <Keys> {
                Keys.OemCloseBrackets, Keys.OemOpenBrackets, Keys.OemSemicolon, Keys.Oemcomma, Keys.OemQuotes, Keys.OemPeriod
            };

            var pickupDelay = 1000;

            var fishRodSimulity       = 0.8;
            var fishRodColorInfoHList = new List <double> {
                10, 20, 30, 40
            };
            var fishRodColorInfoSList = new List <double> {
                65, 75, 85, 95
            };
            var fishRodColorInfoVList = new List <double> {
                16, 22, 28, 34
            };

            var leafColorInfoList = GetLeafColorInfoList(fishRodColorInfoHList, fishRodColorInfoSList, fishRodColorInfoVList);

            var baitBounds = new List <int> {
                screenX / 5, screenY / 5, screenX / 5 * 4, screenY / 4 * 3
            };
            var isBaitOffset = new List <int> {
                120, 30, 0, 60
            };
            var timeOut         = 20000;
            var isBaitColorInfo = new List <string> {
                "FFFBFF", "0.9", "5"
            };

            var fishRodlen = leafColorInfoList.Count;


            var lastTime = DateTime.Now;


            //进入魔兽世界
            //_dmSoft.Delay(5000);
            //_dmSoft.KeyPress((int)Keys.Enter);
            //_dmSoft.Delay(20000);
            //_dmSoft.KeyPress((int)Keys.Escape);
            //_dmSoft.Delay(1000);


            //WheelUp(40);
            AddRod(installRod);
            while (true)
            {
                if (lastTime.AddMinutes(5) <= DateTime.Now)
                {
                    UserWater(waterKey, waterHits);
                    DeleteItem(itemKeyList);
                    lastTime = DateTime.Now;
                }
                AddBait(addBaitKey);
                while (true)
                {
                    //抛竿
                    ThrowFishRod(throwFishRodKey);
                    //抛竿一段时间才能完全显示位置
                    _dmSoft.Delay(fishRodShowDelay);
                    var tmpBaitPosition = new Point();
                    var stack           = new Stack <Point>();
                    for (int fishRodIndex = 0; fishRodIndex < fishRodlen; fishRodIndex++)
                    {
                        var tmpBaitColor = leafColorInfoList[fishRodIndex];
                        tmpBaitPosition = FindBaitPosition(tmpBaitColor, fishRodSimulity, baitBounds);
                        if (tmpBaitPosition.X >= 0 && tmpBaitPosition.Y >= 0)
                        {
                            //移动到鱼饵处
                            _dmSoft.MoveTo(tmpBaitPosition.X, tmpBaitPosition.Y);
                            stack.Push(tmpBaitPosition);
                            if (_dmSoft.GetCursorShape() == "61922884")
                            {
                                break;
                            }
                        }
                    }
                    if (stack.Count > 1)
                    {
                        stack.Pop();
                        tmpBaitPosition = stack.Pop();
                        _dmSoft.MoveTo(tmpBaitPosition.X, tmpBaitPosition.Y);
                    }

                    if (IsBait(isBaitColorInfo, tmpBaitPosition, isBaitOffset, timeOut))
                    {
                        //拉竿
                        PullFishRod();
                        _dmSoft.Delay(pickupDelay);
                        //取鱼
                        PickupFish();
                    }
                }
            }
        }