Exemplo n.º 1
0
        public Device[] GetADBDevices()
        {
            AndroidDebugBridge.Initialize(true);

            List <Device> Devices = AdbHelper.Instance.GetDevices(AndroidDebugBridge.SocketAddress);

            Device[] DevicesArray = Devices.ToArray();

            return(DevicesArray);
        }
Exemplo n.º 2
0
        /// <summary>
        ///启动adb进程
        /// </summary>
        public static bool StartAdbProcess()
        {
            bool result = true;

            try
            {
                if (Util.IsProcessOpen("adb"))
                {
                    result = true;
                }
                else
                {
                    Process p = new Process();
                    p.StartInfo.UseShellExecute = false;
                    p.StartInfo.CreateNoWindow  = true;
                    p.StartInfo.FileName        = adbFilePath;
                    p.StartInfo.Arguments       = "devices";
                    p.Start();
                    try
                    {
                        AndroidDebugBridge.Initialize(true);
                        AndroidDebugBridge.CreateBridge();
                        AndroidDebugBridge.Instance.Start();
                    }
                    catch (Exception)
                    {
                        CleanUpAdbProcess();
                        result = false;
                    }
                }
            }
            catch (Exception e)
            {
                result = false;
            }
            return(result);
        }
Exemplo n.º 3
0
        public static void GetDevicesTest()
        {
            AndroidDebugBridge.Initialize(true);

            List <Device> devices = AdbHelper.Instance.GetDevices(AndroidDebugBridge.SocketAddress);

            foreach (var item in devices)
            {
                //Monitor.
                FileMonitor monitor = new FileMonitor();

                //List of remote files to be downloaded.
                List <FileEntry> files = new List <FileEntry>();

                //First remote file.
                FileEntry file = FileEntry.Find(item, "/data/data/com.netmarble.lin2ws/shared_prefs/NetmarbleNeo_LineageS.xml");

                //Add remote file to list of remote files.
                files.Add(file);

                //Local filename string split character.
                string axe = ":";

                //Local filename.
                string[] f = Regex.Split(item.SerialNumber, axe);

                //Local path + filename.
                string localFilename = "C:\\test\\" + f[f.Length - 1] + ".xml";

                ShellOutputReceiver receiver = new ShellOutputReceiver();

                if (!item.CanSU())
                {
                    MainWindow.main.UpdateLog = "Root Android.";
                }

                try
                {
                    item.ExecuteShellCommand("input mouse tap 640 340", receiver);
                }
                catch (Exception e)
                {
                    MainWindow.main.UpdateLog = e.ToString();
                }



                //Pull file from remote emulator to local folder.
                item.SyncService.Pull(files, "C:\\test\\", monitor);

                //Rename file to adb port number.
                File.Delete(localFilename);
                File.Move("C:\\test\\NetmarbleNeo_LineageS.xml", localFilename);

                //sample code:
                //<string name="LOCAL_PUSH_TARGET">CharacterName</string>
                string text = Xml.FindInnerTextByTagAttribute(localFilename, "string", "name", "LOCAL_PUSH_TARGET");
                MainWindow.main.UpdateLog = text;

                ////testing shell commands
                //ShellOutPRec receiver = new ShellOutPRec( );
                //item.ExecuteShellCommand("ps", receiver);

                ////testing pull command
                //FileMonitor monitor = new FileMonitor();
                //List<FileEntry> files = new List<FileEntry>();
                //FileEntry file = FileEntry.Find(item, "/data/data/com.netmarble.lin2ws/shared_prefs/");
                //files.Add(file);
                //item.SyncService.Pull(files, "shared_prefs", monitor);

                ////testing screencap
                //PixelFormat format = PixelFormat.Format32bppArgb;
                //Image image = item.Screenshot.ToImage(format);

                //MainWindow.main.UpdateLog = item.SerialNumber + ", " + item.State + item.IsEmulator + " - Emulator" + receiver;
            }
        }
Exemplo n.º 4
0
        //HotKey Overload
        private void BtnProcessGrab_Click(object sender, HotkeyEventArgs e)
        {
            //Do NOT forget to also change overload method below
            if (btnProcessGrab.IsEnabled)
            {
                listProcessList.Items.Clear();

                listProcessList.SelectionMode = SelectionMode.Multiple;

                Process[] EmulatorProcess;

                if (CbItemNox.IsSelected)
                {
                    EmulatorProcess = Bot.GetOpenProcess("Nox");

                    if (EmulatorProcess == null)//value check
                    {
                        UpdateLog = "null process value ProcessGrabber_Click";
                        return;
                    }

                    if (EmulatorProcess != null)//enbale buttons for quest if we bind to the Nox player process
                    {
                        EnableButtons();
                        listProcessList.IsEnabled  = true;
                        listProcessList.Background = System.Windows.Media.Brushes.LightGreen;
                    }

                    foreach (Process pro in EmulatorProcess)
                    {
                        if (pro == null)
                        {
                            UpdateLog = "Null Process";

                            return;
                        }

                        ListBoxItem itm = new ListBoxItem()
                        {
                            Content = pro.MainWindowTitle.ToString()
                        };

                        listProcessList.Items.Add(itm);

                        EmulatorCount++;
                    }

                    Emulators = EmulatorProcess;
                }

                if (CbItemBS.IsSelected)
                {
                    EmulatorProcess = Bot.GetOpenProcess("Bluestacks");

                    if (EmulatorProcess == null)//value check
                    {
                        UpdateLog = "Null process value ProcessGrabber_Click";
                        return;
                    }

                    if (EmulatorProcess != null)//enbale buttons for quest if we bind to the Nox player process
                    {
                        EnableButtons();
                        listProcessList.IsEnabled  = true;
                        listProcessList.Background = System.Windows.Media.Brushes.LightGreen;
                    }

                    foreach (Process pro in EmulatorProcess)
                    {
                        if (pro == null)
                        {
                            UpdateLog = "Null Process";

                            return;
                        }

                        if (pro.MainWindowTitle != "")
                        {
                            ListBoxItem itm = new ListBoxItem()
                            {
                                Content = pro.MainWindowTitle.ToString()
                            };

                            listProcessList.Items.Add(itm);

                            EmulatorCount++;
                        }
                    }

                    Emulators = EmulatorProcess;
                }

                if (CbItemMEmu.IsSelected)
                {
                    EmulatorProcess = Bot.GetOpenProcess("MEmu");

                    if (EmulatorProcess == null)//value check
                    {
                        UpdateLog = "Null process value ProcessGrabber_Click";
                        return;
                    }

                    if (EmulatorProcess != null)//enbale buttons for quest if we bind to the Nox player process
                    {
                        EnableButtons();
                        listProcessList.IsEnabled  = true;
                        listProcessList.Background = System.Windows.Media.Brushes.LightGreen;
                    }

                    foreach (Process pro in EmulatorProcess)
                    {
                        if (pro == null)
                        {
                            UpdateLog = "Null Process";

                            return;
                        }

                        if (pro.MainWindowTitle != "")
                        {
                            ListBoxItem itm = new ListBoxItem()
                            {
                                Content = pro.MainWindowTitle.ToString()
                            };

                            listProcessList.Items.Add(itm);

                            EmulatorCount++;
                        }
                    }

                    Emulators = EmulatorProcess;
                }

                if (CbItemADB.IsSelected)
                {
                    AndroidDebugBridge.Initialize(true);

                    //ADB devices.
                    List <Device> Devices = AdbHelper.Instance.GetDevices(AndroidDebugBridge.SocketAddress);

                    L2RDevices = new L2RDevice[Devices.Count];

                    //Initializes the L2RDevice array.
                    for (int i = 0; i < Devices.Count; i++)
                    {
                        L2RDevices[i] = new L2RDevice(Devices[i]);

                        EmulatorCount++;
                    }

                    //Enbale buttons for quest if we find ADB devices.
                    if (Devices != null)
                    {
                        EnableButtons();
                        listProcessList.IsEnabled  = true;
                        listProcessList.Background = System.Windows.Media.Brushes.LightGreen;
                    }

                    foreach (L2RDevice Device in L2RDevices)
                    {
                        if (Device.CharacterName == null)
                        {
                            UpdateLog = "Unable to find Character name";
                        }

                        ListBoxItem itm = new ListBoxItem()
                        {
                            Content = Device.CharacterName
                        };

                        listProcessList.Items.Add(itm);
                    }
                }

                if (listProcessList.HasItems)
                {
                    btnProcessGrab.IsEnabled = false;
                }



                UpdateLog = "Select any process that you would like the bot to ignore.";
            }
        }