admin管理员组

文章数量:1558697

通过adb和python直接传输Android截图到电脑(windows适用)

  • screencap命令
  • adb连接
  • 使用python直接传输到电脑

screencap命令

Android系统的screencap命令是常用的截图操作命令,具体选项如下:

adb shell screencap -help
usage: screencap [-hp] [-d display-id] [FILENAME]
-h: this message
-p: save the file as a png.
-d: specify the display id to capture, default 0.
If FILENAME ends with .png it will be saved as a png.
If FILENAME is not given, the results will be printed to stdout.

其中-p代表输出文件为png文件

adb连接

windows可以安装adb来连接手机安卓系统(需手机支持),安卓模拟器等等,利用这种方式可以实现windows获取Android系统实时界面截图,通常完整的实现方式为:

adb shell screencap -p sdcard/cap.png
adb pull sdcard/cap.png d:\cap.png
adb shell rm sdcard/cap.png

从上到下命令含义为“截图并保存在android内——导出到win——删除android截图文件”;可以看出,这种方式相对笨重

使用python直接传输到电脑

直接传输无需临时存储文件,安全性和效

本文标签: 截图电脑PythonADBWindows