使用adb 控制Android手機, 需先將adb放於path中, 再使用如下程式碼控制
請先下載 adb.exe 及AdbWinUsbApi.dll
public partial class Form1 : Form { Process p; public Form1() { InitializeComponent(); } private void Form1_Load(object sender, EventArgs e) { String cmd = "adb.exe"; p = new Process(); p.StartInfo.FileName = cmd; p.StartInfo.Arguments = "devices"; p.StartInfo.UseShellExecute = false; p.StartInfo.RedirectStandardInput = true; p.StartInfo.RedirectStandardOutput = true; p.StartInfo.RedirectStandardError = true; p.StartInfo.CreateNoWindow = true; //p.Start(); //this.label1.Text = p.StandardOutput.ReadToEnd(); //p.Close(); } private void btVolumeUp_Click(object sender, EventArgs e) { p.StartInfo.Arguments = "shell input keyevent 24"; p.Start(); } private void btVolumeDown_Click(object sender, EventArgs e) { p.StartInfo.Arguments = "shell input keyevent 25"; p.Start(); } }