Example #1
0
        private void button1_Click(object sender, EventArgs e)
        {
            string HeroName  = comboBox1.Text.ToString();
            var    LoLClient = DM.FindWindow("", "League of Legends");

            DM.BindWindow(LoLClient, "gdi", "windows3", "normal", 1);
            DM.MoveTo(860, 97);
            DM.LeftClick();
            DM.Capture(0, 0, 2000, 2000, "1.bmp");
            int isExsit = -1;
            //Enter hero name X Y;
            int    x = 784, y = 100;
            object x1, y2;

            while (true)
            {
                isExsit = DM.FindPic(0, 0, 2000, 2000, "Icon.bmp", "000000", 0.9, 0, out x1, out y2);
                if (isExsit >= 0)
                {
                    DM.MoveTo(860, 97);
                    Thread.Sleep(300);
                    DM.LeftClick();
                    Thread.Sleep(300);
                    foreach (int key in Hero[HeroName])
                    {
                        DM.KeyPress(key);
                    }
                    DM.MoveTo(370, 163);
                    Thread.Sleep(500);
                    DM.LeftClick();
                }
            }
        }
Example #2
0
        public Point FindPic(int x1, int y1, int x2, int y2, string pic_name, int dir = 0, string delta_color = "", double sim = 0.8)
        {
            object x;
            object y;

            dm.FindPic(x1, y1, x2, y2, pic_name, delta_color, sim, dir, out x, out y);
            return(new Point((int)x, (int)y));
        }
Example #3
0
        private Process[] StartPlayers()
        {
            var list = new List <Process>();

            _dmMain = new dmsoft();
            //var x = dmMain.Reg("111", "3.1254");
            var mailProcess = StartDnmultiplayerProcess();
            //var hProcess = (IntPtr)OpenProcess(PROCESS_ALL_ACCESS, false, playerProcess.Id);
            var x111 = mailProcess.MainWindowHandle.ToInt32();
            var bind = _dmMain.BindWindowByCustom(mailProcess);

            if (bind == 0)
            {
                throw new Exception("错误:大漠绑定雷电多开器窗口失败");
            }

            const int topX  = 0;
            var       topY  = 0;
            const int maxX  = 100000;
            const int maxY  = 100000;
            int       index = 0;

            while (true)
            {
                var p = _dmMain.FindPic(topX, topY, maxX, maxY, AppHelper.MapPath("/resources/pics/playerstart.bmp"), "000000", 1.0, 0, out var intX, out var intY);
                var x = (int)intX;
                var y = (int)intY;
                if (x > 0 && y > 0)
                {
                    _dmMain.MoveTo(x + 10, y + 10);
                    _dmMain.LeftClick();
                    //await Task.Delay(TimeSpan.FromSeconds(AppSettings.PlayerStartDelay));
                    var process = GetDnplayer(index);
                    if (process == null)
                    {
                        throw new Exception("错误:未成功启动雷电模拟器");
                    }
                    list.Add(process);

                    topY = y + 2;
                    Task.WaitAll(Task.Delay(TimeSpan.FromSeconds(AppSettings.Player.StartInterval)));
                }
                else
                {
                    break;
                }
            }

            return(list.ToArray());
        }
Example #4
0
        /// <summary>
        /// 查找指定区域内的图片,位图必须是24位色格式,支持透明色,当图像上下左右4个顶点的颜色一样时,则这个颜色将作为透明色处理
        /// 这个函数可以查找多个图片,只返回第一个找到的X Y坐标
        /// </summary>
        /// <param name="dmsoft"></param>
        /// <param name="findPic"></param>
        /// <returns></returns>
        public static Point FindPic(this dmsoft dmsoft, FindPic findPic)
        {
            int x, y;
            var res = dmsoft.FindPic(findPic.X1, findPic.Y1, findPic.X2, findPic.Y2, findPic.PicName, findPic.DeltaColor, findPic.Sim, findPic.Dir, out x, out y);

            if (res != -1)
            {
                return(new Point(x, y));
            }
            else
            {
                return(new Point());
            }
        }
Example #5
0
        //查找图片+点击
        bool FindPic_Click(Pic pic)
        {
            bool finded = false;

            dm.FindPic(0, 0, 960, 540, pic.Path, "000000", 0.9, 0, out int x, out int y);
            if (x > 0 && y > 0)
            {
                finded = true;
                //GameMsg(String.Format("找到{0},坐标为{1},{2}", pic.Name, x, y));
                GameMsg(pic.Name);
                if (pic.X == 0)
                {
                    pic.X = x;
                }
                if (pic.Y == 0)
                {
                    pic.Y = y;
                }
                Move_Click(pic.X, pic.Y);
                Thread.Sleep(1000);
            }
            return(finded);
        }
Example #6
0
        private void StartOpera()
        {
            var    r    = 0;
            object intX = null;
            object intY = null;

            while (r <= 0)
            {
                AppHelper.WaitSeconds(1);
                r = _dm.FindPic(0, 0, 800, 600, AppHelper.MapPath("/resources/pics/login.bmp"), "000000", 1.0, 0, out intX, out intY);
            }
            if (r > 0)
            {
                _dm.MoveTo((int)intX, (int)intY);
                _dm.LeftClick();
            }
        }
Example #7
0
        public static bool FindPic(int x1, int y1, int x2, int y2, string bmp, double sim, out int x, out int y)
        {
            dmsoft dm = GetDm();
            int    width, height;

            dm.GetClientSize(hwnd, out object w, out object h);
            width  = Convert.ToInt32(w);
            height = Convert.ToInt32(h);
            if (width != windowW || height != windowH)
            {
                Outputs.Log("poi浏览器大小改变,即将重新定位游戏窗口");
                Utils.Delay(2000);
                GamePosition();
            }
            DebugBmp(x1, y1, x2, y2, bmp);
            bmp = System.AppDomain.CurrentDomain.BaseDirectory + "bmp\\" + bmp + ".bmp";
            if (!System.IO.File.Exists(bmp))
            {
                Outputs.Msg(bmp + "资源图片缺失,请检查bmp文件夹");
                x = -1;
                y = -1;
                return(false);
            }
            x1 = x1 + gameX1;
            y1 = y1 + gameY1;
            x2 = x2 + gameX1;
            y2 = y2 + gameY1;
            object dx;
            object dy;
            int    res = dm.FindPic(x1, y1, x2, y2, bmp, "000000", sim, 0, out dx, out dy);

            x  = Convert.ToInt32(dx);
            y  = Convert.ToInt32(dy);
            x -= gameX1;
            y -= gameY1;
            if (res != 0)
            {
                return(false);
            }
            if (x < 0 && y < 0)
            {
                return(false);
            }
            return(true);
        }
Example #8
0
        public void SingleMapguaji()
        {
            scriptx = true;

            int x = 0; int y = 0;

            //识别地图,SingleMapguaji传递地图参数
            while (scriptx)
            {
                int ret = dm.FindPic(0, 200, 1279, 902, "草莓.bmp|栗子.bmp|露水.bmp|铁皮.bmp|酒瓶.bmp|垃圾桶.bmp|方便面袋.bmp|鼻涕纸.bmp|鞋子.bmp|炒锅.bmp|易拉罐.bmp|破碗.bmp|破礼帽.bmp|破锅.bmp|苹果核.bmp|农药瓶.bmp|帽子.bmp|轮胎.bmp", "000000", 0.7, 0, out x, out y);//
                if (ret != -1)
                {
                    //Log.WriteTxt("发现食物垃圾");
                    dm.MoveTo(x + 14, y + 14);
                    dm.LeftClick();
                }
                dm.delay(4000);
                //Log.WriteTxt("返回值="+ret);
                //Log.WriteTxt("检查运行中");
            }
            //Log.WriteTxt("exit");
        }
Example #9
0
 public long FindPic(int x1, int y1, int x2, int y2, string imagePath, string deltaColor, double sim, int dir, out object x, out object y)
 {
     return(dm.FindPic(x1, y1, x2, y2, imagePath, deltaColor, sim, dir, out x, out y));
 }