private void btnMonitorTool_Click(object sender, EventArgs e) { if (this.cmbDevice.SelectedIndex < 0) { return; } string device = this.cmbDevice.SelectedValue.ToString(); Button btn = sender as Button; if (btn.Text == "Home") { AdbShell.ReadProcess(device, "shell input keyevent 3"); } else if (btn.Text == "Back") { AdbShell.ReadProcess(device, "shell input keyevent 4"); } else if (btn.Text == "Menu") { AdbShell.ReadProcess(device, "shell input keyevent 82"); } else if (btn.Text == "V+") { AdbShell.ReadProcess(device, "shell input keyevent 24"); } else if (btn.Text == "V-") { AdbShell.ReadProcess(device, "shell input keyevent 25"); } }
private void btnMonitorInput_Click(object sender, EventArgs e) { if (this.cmbDevice.SelectedIndex >= 0) { AdbShell.ReadProcess(this.cmbDevice.SelectedValue.ToString(), "shell input text \"" + this.txtInputContent.Text + "\""); } }
private void btnMonitorClick_Click(object sender, EventArgs e) { if (this.cmbDevice.SelectedIndex >= 0) { AdbShell.ReadProcess(this.cmbDevice.SelectedValue.ToString(), "shell input tap " + this.txtInputX.Text + " " + this.txtInputY.Text); } }
private void btnMonitorSwip_Click(object sender, EventArgs e) { if (this.cmbDevice.SelectedIndex >= 0) { AdbShell.ReadProcess(this.cmbDevice.SelectedValue.ToString(), string.Format("shell input swipe {0} {1} {2} {3} {4}", this.txtStartX.Text, this.txtStartY.Text, this.txtEndX.Text, this.txtEndY.Text, this.txtMiniSeconds.Text)); } }
private void pictureBox1_MouseDown(object sender, MouseEventArgs e) { if (this.cmbDevice.SelectedIndex >= 0) { Regex sizeRegex = new Regex(@"(?<width>\d+)x(?<height>\d+)"); string content = AdbShell.ReadProcess(this.cmbDevice.SelectedValue.ToString(), "shell wm size"); int width = int.Parse(sizeRegex.Match(content).Groups["width"].Value); int height = int.Parse(sizeRegex.Match(content).Groups["height"].Value); // adb shell wm size this.txtClickPoint.Text = (e.Location.X * width / this.pictureBox1.Width) + "," + (e.Location.Y * height / this.pictureBox1.Height); } }
private void btnReadActivity_Click(object sender, EventArgs e) { if (this.cmbDevice.SelectedIndex >= 0) { string result = AdbShell.ReadProcess(this.cmbDevice.SelectedValue.ToString(), "shell dumpsys activity | grep \"mFocusedActivity\""); // mFocusedActivity: ActivityRecord{530bfdb4 u0 com.estrongs.android.pop/.view.FileExplorerActivity t4} Regex activityRegex = new Regex(@"\s(?<package>[^/\s]+)/(?<activity>[^/\s]+)"); string package = activityRegex.Match(result).Groups["package"].Value; string activity = activityRegex.Match(result).Groups["activity"].Value; this.txtActivity.Text = package + "/" + activity; } }
private void LoadViewWhileTrue() { if (this.cmbDevice.SelectedIndex < 0) { return; } string device = this.cmbDevice.SelectedValue.ToString(); string monitor_path = @"/sdcard/screenshot.png"; string pc_path = @"D:\screenshot.png"; while (this.chkAutoRefreshUI.Checked) { try { if (!File.Exists(pc_path)) { File.Create(pc_path); } string content = AdbShell.ReadProcess(device, "shell /system/bin/screencap -p " + monitor_path); content = AdbShell.ReadProcess(device, "pull " + monitor_path + " " + pc_path); Thread.Sleep(1000); if (!File.Exists(pc_path)) { Thread.Sleep(1000); } var bs = File.ReadAllBytes(pc_path); using (MemoryStream ms = new MemoryStream(bs)) { Image img = Image.FromStream(ms); this.Invoke(new Action <PictureBox>(p => p.Image = img), this.pictureBox1); } } catch { } finally { Thread.Sleep(int.Parse(this.txtRefreshMimiSeconds.Text)); } } this.btnRefreshView.Enabled = true; }