async static Task MainAsync() { AdbClient Client = new AdbClient(); Stopwatch StopWatch = new Stopwatch(); List <Emulator> Emulators = new List <Emulator>(); List <UIObject> Objects = new List <UIObject>(); while (true) { Emulators = Client.GetEmulators(); Emulators.ForEach(Emulator => Console.WriteLine($"Emulator:{Emulator.EndPoint.Address}:{Emulator.EndPoint.Port}\n")); await Task.Delay(1000); Console.Write("> "); string Command = Console.ReadLine(); List <string> Result; XmlDocument UIXmlDocument; Console.WriteLine(""); try { if (Command == "scan") { Emulators = Client.GetEmulators(); Emulators.ForEach(Emulator => Console.WriteLine($"Emulator:{Emulator.EndPoint.Address}:{Emulator.EndPoint.Port}\n")); } else if (Command.StartsWith("select")) { throw new NotImplementedException(); } else if (Command.StartsWith("ui")) { StopWatch.Start(); UIXmlDocument = await Emulators[0].Shell.GetUIXml(); StopWatch.Stop(); Objects = UIParser(UIXmlDocument); DrawUITree(Objects); } else if (Command.StartsWith("pull")) { StopWatch.Start(); await Emulators[0].Sync.Pull(Command.Split('"')[1]); StopWatch.Stop(); Console.WriteLine("[Task Completed]"); } else if (Command.StartsWith("install")) { StopWatch.Start(); Console.WriteLine(await Emulators[0].Install.Apk(Command.Split('"')[1])); StopWatch.Stop(); } else if (Command.StartsWith("root")) { StopWatch.Start(); Console.WriteLine(await Emulators[0].Root.Enable()); StopWatch.Stop(); } else if (Command.StartsWith("mini")) { StopWatch.Start(); UIXmlDocument = await Emulators[0].Shell.GetUIXml(); StopWatch.Stop(); if (Objects.Count == 0) { Objects = UIParser(UIXmlDocument); } string Shell = GenerateShell(Objects, Command); await Emulators[0].Shell.Excute(Shell); } else { StopWatch.Start(); Result = await Emulators[0].Shell.Excute(Command); StopWatch.Stop(); Result.ForEach(Line => Console.WriteLine(Line)); } } catch (Exception Error) { StopWatch.Stop(); Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine($"Error: {Error.Message}"); Console.ForegroundColor = ConsoleColor.Green; } Console.ForegroundColor = ConsoleColor.Yellow; Console.WriteLine($"\nTime Taken: {StopWatch.ElapsedMilliseconds.ToString("d")} Milliseconds"); Console.ForegroundColor = ConsoleColor.Green; StopWatch.Reset(); Console.WriteLine(""); } }