-
-
Save lovmoon3k/653cb54f629bfcfdd48ed442d7d8b22a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static class AdbHelper | |
{ | |
public static string AdbPath = "adb.exe"; | |
public static MemoryStream ExecuteCommandBuffer(string command) | |
{ | |
using(Process process = new Process()) | |
{ | |
process.StartInfo.FileName = AdbPath; | |
process.StartInfo.WorkingDirectory = Directory.GetCurrentDirectory(); | |
process.StartInfo.Arguments = command; | |
process.StartInfo.CreateNoWindow = true; | |
process.StartInfo.UseShellExecute = false; | |
process.StartInfo.RedirectStandardOutput = true; | |
process.StartInfo.RedirectStandardError = true; | |
process.StartInfo.RedirectStandardInput = true; | |
process.Start(); | |
MemoryStream memoryStream = new MemoryStream(); | |
process.StandardOutput.BaseStream.CopyTo(memoryStream); | |
process.WaitForExit(); | |
returrn memoryStream; | |
} | |
} | |
public static Bitmap ScreenShot(string deviceId) | |
{ | |
string args = $"-s {DeviceId} exec-out screencap -p"; | |
var stream = ExecuteCommandBuffer(args); | |
return (Bitmap)Bitmap.FromStream(stream); | |
} | |
public static void Main() | |
{ | |
using(Bitmap bitmap = ScreenShot("deviceId")) | |
{ | |
bitmap.Save("D:\\test.png"); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment