Example #1
0
        /// <summary>
        /// 新建模拟器并得到新建模拟器的index
        /// </summary>
        public static int addSimulator()
        {
            int     res     = -1;
            MyLdcmd myldcmd = MyLdcmd.GetObject();

            lock (obj)
            {
                int[] dq = getDqmoniqiIndex();
                foreach (int a in dq)
                {
                    //WriteLog.WriteLogFile("", a+"号模拟器");
                }
                ld.AddSimulator();
                int[] dq2 = getDqmoniqiIndex();
                foreach (int a in dq2)
                {
                    //WriteLog.WriteLogFile("", "新增后,"+a + "号模拟器");
                }
                foreach (int a in dq2)
                {
                    if (!dq.Contains <int>(a))
                    {
                        res = a;
                        modifySimulator(res);
                        WriteLog.WriteLogFile("", res + "号模拟器是新增的");
                    }
                }
            }
            return(res);
        }
Example #2
0
        public int qushufrombaidu_gaoqing(myDm mf, int dqinx, int jubing, int x1, int y1, int x2w, int y2h)
        {
            WriteLog.WriteLogFile(dqinx + "", "先截图再取数gaoqing");
            int    qushu     = -1;
            string timestamp = mf.GetTime() + "";
            string mydir1    = @"d:\mypic_save\" + timestamp + ".png";

            MyLdcmd.myScreencap(dqinx, mydir1);
            System.Drawing.Bitmap f = MyFuncUtil.ReadImageFile(mydir1);
            if (f != null)
            {
                System.Drawing.Bitmap g = MyFuncUtil.KiCut(f, x1, y1, x2w, y2h);
                g.Save(@"d:\mypic_save\" + timestamp + "_1.jpg");
                g.Dispose();
            }
            if (File.Exists(@"d:\mypic_save\" + timestamp + "_1.jpg"))
            {
                string r = shuzishibie(dqinx, @"d:\mypic_save\" + timestamp + "_1.jpg");
                if (r != null && r != "")
                {
                    qushu = int.Parse(r);
                    WriteLog.WriteLogFile(dqinx + "", " 高清取数的结果" + qushu);
                }
            }
            return(qushu);
        }
Example #3
0
        public void myReSize(int index, out int width, out int height, string youxi = "luneng", string dizhi = @"d:\ChangZhi\dnplayer2\")
        {
            WriteLog.WriteLogFile(index + "", "模拟器" + index + "开始改位置");
            int dqwidth  = 2560; //1920 1024
            int dqheight = 1440; //1080 768
            int yiquanw  = 601;
            int yiquany  = 338;

            if (youxi.Equals("luneng"))
            {
                yiquanw = 727; //原来外框 727 425
                yiquany = 425;
            }
            width  = yiquanw;
            height = yiquany;
            int    jubing = MyLdcmd.getDqmoniqiWaiCengJuBingByIndex(index, dizhi);
            IntPtr p      = new IntPtr(jubing);
            IntPtr p2     = new IntPtr(HWND_TOP);
            int    x      = 0;
            int    y      = 0;

            x = (index % 4) * (dqwidth / 4);
            y = (index / 4) * (dqheight / 4);
            WriteLog.WriteLogFile(index + "", index + "x:" + x + ",y:" + y);
            if (youxi.Equals("luneng"))
            {
                SetWindowPos(p, p2, x, y, yiquanw, yiquany, SWP_SHOWWINDOW);
            }
            else
            {
                SetWindowPos(p, p2, x, y, yiquanw, yiquany, SWP_SHOWWINDOW);
            }
        }
Example #4
0
        public static void myReSizeNeiKuang(int index, out int width, out int height, string dizhi = @"d:\ChangZhi\dnplayer2\", string youxi = "luneng")
        {
            mylogandxianshi("模拟器内框" + index + "开始改位置");
            int dqwidth  = 1920; //1920 1024
            int dqheight = 1080; //1080 768
            int yiquanw  = 601;
            int yiquany  = 338;

            if (youxi.Equals("luneng"))
            {
                yiquanw = 688; //原来外框 727 425
                yiquany = 387;
            }
            width  = yiquanw;
            height = yiquany;
            lock (obj)
            {
                int    jubing = MyLdcmd.getDqmoniqiJuBingByIndex(index, dizhi);
                IntPtr p      = new IntPtr(jubing);
                IntPtr p2     = new IntPtr(HWND_TOP);
                int    x      = 0;
                int    y      = 0;
                x = (index % 4) * (dqwidth / 4);
                y = (index / 4) * (dqheight / 4);
                mylogandxianshi(index + "x:" + x + ",y:" + y);
                if (youxi.Equals("luneng"))
                {
                    SetWindowPos(p, p2, x + 20, y + 19, yiquanw, yiquany, SWP_SHOWWINDOW);
                }
                else
                {
                    SetWindowPos(p, p2, x, y, yiquanw, yiquany, SWP_SHOWWINDOW);
                }
            }
        }
Example #5
0
        public static void myCopySimulator(int shuliang, string dizhi)
        {
            MyLdcmd myldcmd = MyLdcmd.GetObject(dizhi);
            int     i       = 0;

            while (true)
            {
                MyFuncUtil.mylogandxianshi((i++) + "个模拟器开始复制");
                int[] moniqiIndex = getDqmoniqiIndex(dizhi);
                try
                {
                    LogWriteLock.EnterWriteLock();
                    ld.CopySimulator(0);
                }
                catch { }
                finally
                {
                    LogWriteLock.ExitWriteLock();
                }
                Thread.Sleep(40000);
                if (moniqiIndex.Length >= shuliang)
                {
                    break;
                }
            }
        }
Example #6
0
        public static void BackupAndlunch(int index, string backname, string a_b)
        {
            WriteLog.WriteLogFile(index + "", "准备关闭并备份");
            Thread.Sleep(10000);
            string dizhi = null;
            string path  = null;
            string seed  = null;

            myqiehuancd(a_b, out dizhi, out path, out seed);
            myQuit(index, dizhi);
            Thread.Sleep(2000);
            zaiciguanbi();
            if (backname.Length > 0)
            {
                WriteLog.WriteLogFile(index + "", "值得备份的" + backname);
                Thread.Sleep(20000);
                MyLdcmd.myBackup(index, @"c:\mypic_save\" + backname, dizhi);
            }
            Thread.Sleep(30000);
            try
            {
                LogWriteLock.EnterReadLock();
                MyLdcmd.myRestore(index, seed, dizhi);
            }
            catch { }
            finally
            {
                LogWriteLock.ExitReadLock();
            }
            Thread.Sleep(40000);
            MyLdcmd.myRename(index, "雷电模拟器-" + index, dizhi);
            Thread.Sleep(5000);
        }
Example #7
0
        public static void myRename(int index, string name, string dizhi)
        {
            MyLdcmd myldcmd = MyLdcmd.GetObject(dizhi);

            myldcmd.SimulatorPath = ld.SimulatorPath;
            myldcmd.rename(index, name);
        }
Example #8
0
        public static void MyRestore(int index, string backname, string a_b)
        {
            WriteLog.WriteLogFile(index + "", "准备关闭并备份");
            Thread.Sleep(10000);
            string dizhi = null;
            string path  = null;
            string seed  = null;

            myqiehuancd(a_b, out dizhi, out path, out seed);
            if (backname.Length > 0)
            {
                myQuit(index, dizhi);
                Thread.Sleep(2000);
                zaiciguanbi();
                WriteLog.WriteLogFile(index + "", "值得备份的" + backname);
                Thread.Sleep(20000);
                MyLdcmd.myBackup(index, @"c:\mypic_save\" + backname, dizhi);
                Thread.Sleep(30000);
            }
            else
            {
                myQuit(index, dizhi);
                Thread.Sleep(2000);
                zaiciguanbi();
            }
        }
Example #9
0
        public static void myQuitAll(string dizhi)
        {
            MyLdcmd myldcmd = MyLdcmd.GetObject(dizhi);

            MyFuncUtil.killProcess("dnplayer");
            Thread.Sleep(10000);
            int[] abcd = getDqmoniqiHuodongIndex(dizhi);
            foreach (var a in abcd)
            {
                if (a == -1)
                {
                    continue;
                }
                while (true)
                {
                    int[]     abc = getDqmoniqiHuodongIndex(dizhi);
                    ArrayList ar  = new ArrayList(); //实例化一个ArrayList
                    ar.AddRange(abc);                //把数组赋到Arraylist对象
                    if (ar.Contains(a))
                    {
                        MyFuncUtil.mylogandxianshi("关闭模拟器" + a);
                        ld.Quit(a);
                    }
                    if (!ar.Contains(a))
                    {
                        MyFuncUtil.mylogandxianshi("模拟器" + a + ",关闭成功");
                        break;
                    }
                }
            }
        }
Example #10
0
        public static void myBackup(int index, string path, string dizhi)
        {
            MyLdcmd myldcmd = MyLdcmd.GetObject(dizhi);

            myldcmd.SimulatorPath = ld.SimulatorPath;
            myldcmd.backUp(index, path);
        }
Example #11
0
        /// <summary>
        /// 根据模拟器的句柄得到模拟器的名字
        /// </summary>
        /// <param name="jubing"></param>
        /// <returns></returns>
        public static string getMoniqiNameByJubing(int jubing, string dizhi)
        {
            string[] getApp  = getDqmoniqiJuBing(dizhi);
            int      dqindex = -1;
            string   rs      = null;

            foreach (string s in getApp)
            {
                string[] b   = s.Split('|');
                int      zt  = int.Parse(b[1]);
                int      ind = int.Parse(b[0]);
                if (jubing == zt)
                {
                    dqindex = ind;
                }
            }
            string[] getApp2 = MyLdcmd.getDqmoniqiJinRuAnd(dizhi);
            foreach (string s in getApp2)
            {
                string[] b    = s.Split('|');
                int      zt   = int.Parse(b[2]);
                int      ind  = int.Parse(b[0]);
                string   name = b[1];
                if (dqindex == ind)
                {
                    rs = name;
                }
            }
            return(rs);
        }
Example #12
0
        /// <summary>
        /// 仅得到活动模拟器的index
        /// </summary>
        /// <returns></returns>
        public static int[] getDqmoniqiHuodongIndex(string dizhi)
        {
            string[] getApp = MyLdcmd.getDqmoniqiJinRuAnd(dizhi);
            int      mysize = getApp.Length;

            if (mysize <= 0)
            {
                mysize = 1;
            }

            int[] result = new int[mysize];
            int   i      = 0;

            foreach (string s in getApp)
            {
                string[] b   = s.Split('|');
                int      zt  = int.Parse(b[2]);
                int      ind = int.Parse(b[0]);
                if (zt == 1)
                {
                    result[i] = ind;
                }
                else
                {
                    result[i] = -1;
                }
                i++;
            }

            return(result);
        }
Example #13
0
        public static bool PanDuan_Qidong(string a_b, int dqinx)
        {
            //大框 原始 376 668 横过来后 960 540
            //小框 原始 217 387 横过来后216 122
            //1920 分辨率  2560 1440
            string dizhi = null;
            string path  = null;
            string seed  = null;

            MyFuncUtil.myqiehuancd(a_b, out dizhi, out path, out seed);
            myDm dm     = new myDm();
            int  x1     = -1;
            int  y1     = -1;
            int  jubing = MyLdcmd.getDqmoniqiJuBingByIndex(dqinx, dizhi);

            if (jubing <= 0)
            {
                WriteLog.WriteLogFile(dqinx + "", "游戏判断启动,句柄绑定错误");
                return(false);
            }
            dm.myGetClientRect(jubing, out x1, out y1);
            if (y1 != 540 && y1 != 122 && y1 != 668 && y1 != 432)
            {
                WriteLog.WriteLogFile(dqinx + "", "游戏启动不成功,界面有微信图标 " + x1 + " " + y1);
                return(false);
            }
            return(true);
        }
Example #14
0
        public static void ClearAndCopySimulator(string a_b)
        {
            MyFuncUtil.mylogandxianshi("关闭全部模拟器");
            string dizhi = null;
            string path  = null;
            string seed  = null;

            MyFuncUtil.myqiehuancd(a_b, out dizhi, out path, out seed);
            MyLdcmd myldcmd = MyLdcmd.GetObject(dizhi);

            myQuitAll(dizhi);
            Thread.Sleep(20000);
            MyFuncUtil.mylogandxianshi("删除全部模拟器");
            myRemoveAll(dizhi);
            Thread.Sleep(20000);
            MyFuncUtil.mylogandxianshi("模拟器0复原");
            myRestore(0, seed, dizhi);
            Thread.Sleep(30000);
            MyFuncUtil.mylogandxianshi("开始模拟器复制");
            int sl = 0;

            if (a_b.ToLower().Equals("c"))
            {
                sl = 19;
            }
            if (a_b.ToLower().Equals("d"))
            {
                sl = 21;
            }
            myCopySimulator(sl, dizhi);
            Thread.Sleep(20000);
        }
Example #15
0
        public static void myReboot(int index, string dizhi = @"d:\ChangZhi\dnplayer2\")
        {
            MyLdcmd myldcmd = MyLdcmd.GetObject(dizhi);

            myldcmd.SimulatorPath = ld.SimulatorPath;

            myldcmd.reboot(index);
        }
Example #16
0
        public static void myScreencapLuneng(int index, string path, string sdcardpath = "Pictures")
        {
            MyLdcmd myldcmd = MyLdcmd.GetObject();
            string  zd      = "/sdcard/" + sdcardpath;

            myldcmd.SimulatorPath = ld.SimulatorPath;
            myldcmd.pullFile(index, path, zd);
        }
Example #17
0
        /// <summary>
        /// 启动应用
        /// </summary>
        /// <param name="index">模拟器序号</param>
        /// <param name="value">包名/Activity类名</param>
        /// <returns></returns>
        public static string StartApp(int index, string value)
        {
            MyLdcmd md = MyLdcmd.GetObject();
            string  a  = md.ImplementCmd(string.Format("{0}ld -s {1} am start -n {2}", md.SimulatorPath, index, value));

            WriteLog.WriteLogFile(index + "", string.Format("{0}ld -s {1} am start -n {2}", md.SimulatorPath, index, value));
            return(a);
        }
Example #18
0
        public static void myLaunch(string dizhi, int dqinx, string apkname)
        {
            MyLdcmd myldcmd = MyLdcmd.GetObject(dizhi);

            myldcmd.SimulatorPath = ld.SimulatorPath;
            string a = myldcmd.Launch(dqinx);

            WriteLog.WriteLogFile("", a);
        }
Example #19
0
        public static void myClearAppData(string dizhi, int dqinx, string apkname)
        {
            MyLdcmd myldcmd = MyLdcmd.GetObject(dizhi);

            myldcmd.SimulatorPath = ld.SimulatorPath;
            string a = ld.ClearAppData(dqinx, apkname);

            WriteLog.WriteLogFile("", a);
        }
Example #20
0
        public static void myRestore(int index, string seed, string dizhi)
        {
            MyLdcmd myldcmd = MyLdcmd.GetObject(dizhi);

            myldcmd.SimulatorPath = ld.SimulatorPath;
            lock (obj){
                myldcmd.restore(index, seed);
                Thread.Sleep(1000 * 20);
            }
        }
Example #21
0
        /// <summary>
        /// 修改模拟器默认属性设置
        /// </summary>
        public static void modifySimulator(int index)
        {
            MyLdcmd myldcmd = MyLdcmd.GetObject();

            lock (obj)
            {
                myldcmd.ImplementCmd(string.Format("{0}dnconsole modify --index {1} --resolution 540,960,240 --cpu 1 --memory 1024 --imei auto", myldcmd.SimulatorPath, index));
                WriteLog.WriteLogFile(index + "", string.Format("{0}dnconsole modify --index {1} --resolution 540,960,240 --cpu 1 --memory 1024 --imei auto", myldcmd.SimulatorPath, index));
            }
        }
Example #22
0
 public static void duokaiqiRemoveAll()
 {
     zaiciguanbi();
     WriteLog.WriteLogFile("", "打开模拟器,删除所有模拟器");
     int[] moniqiIndex = MyLdcmd.getDqmoniqiIndex();
     if (moniqiIndex.Length <= 1)
     {
         WriteLog.WriteLogFile("", "模拟器只有一个,不用删除");
         return;
     }
     lock (obj)
     {
         myDm dm = new myDm();
         int  jb = dm.FindWindowEx(0, "", "雷电多开器");
         if (jb <= 0)
         {
             WriteLog.WriteLogFile("", "多开器未找到");
             return;
         }
         int res = dm.bindWindow(jb);
         if (res > 0)
         {
             dm.mytap_duokai(jb, 24, 631);
             Thread.Sleep(2000);
             dm.mytap_duokai(jb, 125, 628);
             Thread.Sleep(2000);
             int jb2 = dm.FindWindowEx(0, "assistantupdateframe", "");
             if (jb2 <= 0)
             {
                 WriteLog.WriteLogFile("", "多开器弹出框未找到");
                 return;
             }
             myDm dm2  = new myDm();
             int  res2 = dm2.bindWindow(jb2);
             if (res2 > 0)
             {
                 dm2.click(92, 127, 300);
                 Thread.Sleep(1000 * 3);
             }
             int jb3 = dm.FindWindowEx(0, "MessageBoxWindow", "");
             if (jb3 <= 0)
             {
                 WriteLog.WriteLogFile("", "是否删除所有盘未找到");
                 return;
             }
             myDm dm3  = new myDm();
             int  res3 = dm3.bindWindow(jb3);
             if (res3 > 0)
             {
                 dm3.click(279, 176, 300);
                 Thread.Sleep(1000 * 6);
             }
         }
     }
 }
Example #23
0
        public static bool isLaunch(int index, string dizhi = @"d:\ChangZhi\dnplayer2\")
        {
            var res = false;

            int[] abc = MyLdcmd.getDqmoniqiHuodongIndex(dizhi);
            if (abc.Contains(index))
            {
                res = true;
            }
            return(res);
        }
Example #24
0
        public static void myScreencap(int index, string path, string dizhi = @"d:\ChangZhi\dnplayer2\")
        {
            MyLdcmd myldcmd = MyLdcmd.GetObject(dizhi);
            string  zd      = "/sdcard/screencap.png";
            string  a       = ld.Screencap(index, zd);

            WriteLog.WriteLogFile(index + "", a);
            Thread.Sleep(3000);
            myldcmd.SimulatorPath = ld.SimulatorPath;
            myldcmd.pullFile(index, path, zd);
        }
Example #25
0
        public static bool lureninstallOk(int dqinx, string apppackage, Action myinstall)
        {
            WriteLog.WriteLogFile(dqinx + "", "检测安装是否成功" + apppackage);
            bool t = false;
            //隔30秒检测是否安装成功
            long ksjs   = MyFuncUtil.GetTimestamp();
            long ks     = MyFuncUtil.GetTimestamp();
            long ks2    = MyFuncUtil.GetTimestamp();
            bool luren  = false;
            int  yici   = 0;
            int  zhuang = 0;

            while (true)
            {
                if (yici == 0)
                {
                    yici = 1;
                    WriteLog.WriteLogFile(dqinx + "", "开头要检测安装一次" + apppackage);
                    luren = MyLdcmd.jingjieisok(dqinx, apppackage);
                    if (!luren)
                    {
                        WriteLog.WriteLogFile(dqinx + "", "开头不成功,安装一次" + apppackage);
                        myinstall();
                    }
                }
                long js = MyFuncUtil.GetTimestamp();
                if ((js - ks) > 30 * 1000)
                {
                    luren = MyLdcmd.jingjieisok(dqinx, apppackage);
                    ks    = MyFuncUtil.GetTimestamp();
                    WriteLog.WriteLogFile(dqinx + "", "30s检测安装一次" + apppackage + "检测结果:" + luren);
                }
                if ((js - ksjs) > 4 * 60 * 1000)
                {
                    WriteLog.WriteLogFile(dqinx + "", "4分钟了,安装app没成功" + apppackage);
                    break;
                }
                if (luren)
                {
                    WriteLog.WriteLogFile(dqinx + "", "安装app成功" + apppackage);
                    t = true;
                    break;
                }
                if (zhuang < 1 && !luren && (js - ks2) > 60 * 1000)
                {
                    WriteLog.WriteLogFile(dqinx + "", "准备安装app,restore或者install");
                    myinstall();
                    ks2 = MyFuncUtil.GetTimestamp();
                    zhuang++;
                }
            }
            return(t);
        }
Example #26
0
        public static void myDownCpu(int index, int rate, string dizhi = @"d:\ChangZhi\dnplayer2\")
        {
            MyLdcmd myldcmd = MyLdcmd.GetObject(dizhi);

            myldcmd.SimulatorPath = ld.SimulatorPath;
            string a = "";

            lock (obj)
            {
                a = ld.Downcpu(index, rate);
            }
            WriteLog.WriteLogFile(index + "", a);
        }
Example #27
0
        /// <summary>
        /// 查看已创建的模拟器状态 PS:依次是:索引,标题,顶层窗口句柄,绑定窗口句柄,是否进入android,进程PID,VBox进程PID
        /// </summary>
        /// <returns>直接返回List集合</returns>
        public static List <String> GetListSimulator(string dizhi)
        {
            MyLdcmd       myldcmd = MyLdcmd.GetObject(dizhi);
            List <string> slist   = ld.ListSimulator();

            if ((slist.Count > 0))
            {
                return(slist);
            }
            myldcmd.SimulatorPath = ld.SimulatorPath;
            slist = myldcmd.ListSimulator();
            return(slist);
        }
Example #28
0
        public static void myRemove(int dqinx, string dizhi = @"d:\ChangZhi\dnplayer2\")
        {
            MyLdcmd myldcmd = MyLdcmd.GetObject(dizhi);

            int[] moniqiIndex = getDqmoniqiIndex(dizhi);
            lock (obj)
            {
                if (moniqiIndex.Contains(dqinx))
                {
                    ld.RemoveSimulator(dqinx);
                }
            }
            WriteLog.WriteLogFile(dqinx + "", dqinx + "号模拟器已经移除");
        }
Example #29
0
        public static string IsRunning(int index, string path, string dizhi)
        {
            MyLdcmd myldcmd = MyLdcmd.GetObject(dizhi);

            myldcmd.SimulatorPath = ld.SimulatorPath;
            string a = myldcmd.isrunning(index, path);

            string[] str = Regex.Split(a, "\r\n", RegexOptions.IgnoreCase);
            foreach (string ab in str)
            {
                //WriteLog.WriteLogFile("", a);
            }
            return(str[4]);
        }
Example #30
0
        /// <summary>
        /// 得到当前模拟器的句柄和索引
        /// </summary>
        /// <param name="ldcmd"></param>
        /// <returns></returns>
        public static string[] getDqmoniqiJuBing(string dizhi = @"d:\ChangZhi\dnplayer2\")
        {
            List <string> slist = MyLdcmd.GetListSimulator(dizhi);

            string[] result = new string[slist.Count];
            int      i      = 0;

            foreach (string s in slist)
            {
                string[] a = s.Split(',');
                result[i] = a[0] + "|" + a[3];
                i++;
            }

            return(result);
        }