private void SendSwipe(int x1, int y1, int x2, int y2) { CmdBuilder cmd = new CmdBuilder() { Command = "adb" }; cmd.UpdateInputArgs("Shell", "shell"); cmd.UpdateInputArgs("Input", "input"); cmd.UpdateInputArgs("InputType", "swipe"); cmd.UpdateInput("TapX1", x1.ToString()); cmd.UpdateInput("TapY1", y1.ToString()); cmd.UpdateInput("TapX2", x1.ToString()); cmd.UpdateInput("TapY2", y1.ToString()); CommandExcutor excutor = new CommandExcutor(cmd); excutor.Excute(); }
private async void _BTNSendCom_Click(object sender, RoutedEventArgs e) { state.UpdateCmdStdOut("\n"); CmdBuilder cmd = new CmdBuilder() { Command = "adb" }; cmd.UpdateInputArgs("args", _TBCommand.Text); CommandExcutor excutor = new CommandExcutor(cmd); var stdout = await excutor.AsyncExcute(5000); state.UpdateCmdStdOut(stdout["StdOut"]); state.UpdateCmdStdOut(@"Command Sended!Waiting for Screencap..."); state.Screencap = await AsyncScreencap(0); state.UpdateCmdStdOut(@"Screencap Recieved!"); }
public BitmapImage Screencap(int delay = 100) { string pngName = string.Format("screencap_{0:D5}.png", new Random().Next(99999)); string pngPathOnPhone = string.Format("/sdcard/{0}", pngName); string pngPath = System.IO.Path.Combine(System.IO.Path.GetTempPath(), pngName); BitmapImage result = null; CmdBuilder cmd = new CmdBuilder() { Command = "adb" }; cmd.UpdateInputArgs("Shell", "shell"); cmd.UpdateInputArgs("Screencap", "screencap"); cmd.UpdateInputArgs("SaveAsPng", "-p"); cmd.UpdateOutput("Output", pngPathOnPhone); CommandExcutor excutor = new CommandExcutor(cmd); Thread.Sleep(delay); //wait for phone's response excutor.Excute(); cmd = new CmdBuilder() { Command = "adb" }; cmd.UpdateInputArgs("Pull", "pull"); cmd.UpdateInput("Input", pngPathOnPhone); cmd.UpdateOutput("Output", pngPath); excutor = new CommandExcutor(cmd); excutor.Excute(); result = ImageLoader.Open(pngPath); File.Delete(pngPath); cmd = new CmdBuilder() { Command = "adb" }; cmd.UpdateInputArgs("Shell", "shell"); cmd.UpdateInputArgs("Delete", "delete"); cmd.UpdateInput("Input", pngPathOnPhone); excutor = new CommandExcutor(cmd); excutor.Excute(); return(result); }