Esempio n. 1
0
        /// <summary>
        /// Takes a screenshot on the device via adb, then pulls the screenshot to a temporary file and returns the filename to it.
        /// </summary>
        /// <param name="strDevice">The device serial number to use.</param>
        /// <returns>Path to a temporary png file of the screenshot.</returns>
        public static string PullScreenshot(string strDevice)
        {
            if (!AllOK()) {
            return "";
              }

              FormProgressBar pb = new FormProgressBar(null);
              pb.Text = "Taking Android screenshot...";
              pb.progressBar.Value = 0;
              pb.Show();

              string strAndroidPath = TempPath + "ClipuploadScreenshot.png";

              Process.Start(new ProcessStartInfo("adb.exe", "-s " + strDevice + " shell  screencap -p \"" + strAndroidPath + "\"") {
            UseShellExecute = false,
            CreateNoWindow = true
              }).WaitForExit();

              pb.progressBar.Value = 51;
              pb.progressBar.Value = 50;
              Application.DoEvents();

              string strTempFile = Path.GetTempFileName() + "_ClipuploadScreenshot.png";

              Process.Start(new ProcessStartInfo("adb.exe", "-s " + strDevice + " pull \"" + strAndroidPath + "\" \"" + strTempFile + "\"") {
            UseShellExecute = false,
            CreateNoWindow = true
              }).WaitForExit();

              pb.Close();

              return strTempFile;
        }
Esempio n. 2
0
        /// <summary>
        /// Pull the last recorded video capture mp4 from the device to a temporary file and returns the filename to it.
        /// </summary>
        /// <returns>Path to a temporary mp4 file of the video.</returns>
        public static string PullRecording(string strDevice)
        {
            if (adbRecording != null) {
            throw new Exception("Still recording.");
              }

              // have to wait for half a second to make sure the device has properly closed the file
              Thread.Sleep(500);

              FormProgressBar pb = new FormProgressBar(null);
              pb.Text = "Pulling Android video...";
              pb.progressBar.Value = 0;
              pb.Show();

              string strAndroidPath = TempPath + "ClipuploadVideo.mp4";
              string strTempFile = Path.GetTempFileName() + "_ClipuploadVideo.mp4";

              Process.Start(new ProcessStartInfo("adb.exe", "-s " + strDevice + " pull \"" + strAndroidPath + "\" \"" + strTempFile + "\"") {
            UseShellExecute = false,
            CreateNoWindow = true
              }).WaitForExit();

              pb.Close();

              return strTempFile;
        }