コード例 #1
0
        public static bool GamePosition()
        {
            object w, h;
            int    width, height, x, y;
            dmsoft dm = GetDm();

            dm.GetClientSize(hwnd, out w, out h);
            width   = Convert.ToInt32(w);
            height  = Convert.ToInt32(h);
            windowW = width;
            windowH = height;
            Outputs.Log("定位游戏窗口中,请勿更改poi浏览器大小");
            gameX1 = 0;
            gameY1 = 0;
            if (!FindPic(0, 0, width, height, "position", 0.9, out x, out y))
            {
                Outputs.Log("未找到游戏窗口");
                return(false);
            }
            gameX1 = x - 1;
            gameY1 = y + 1;
            DebugBmp(0, 0, gameW - 1, gameH - 1, "t");
            Outputs.Log("游戏窗口已更新:" + "x" + gameX1.ToString() + "y" + gameY1.ToString());
            return(true);
        }
コード例 #2
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);
        }