【问题标题】:capture android device screenshot with adb & perl [duplicate]使用 adb 和 perl 捕获 android 设备屏幕截图 [重复]
【发布时间】:2018-02-08 05:05:19
【问题描述】:

我尝试了通过 adb 捕获屏幕截图的单线解决方案,并且文件在 PC 上成功创建,但无法读取:

 C:\Program Files\Android\android-sdk\platform-tools>adb shell screencap -p | perl -pe 's/\x0D\x0A/\x0A/g' > c:\users\utilisateur\desktop\android_screenshot1.png

该文件似乎是正确的,但我认为 Magic 不正确:

编辑: Git Bash for Windows 也出现了同样的问题。

【问题讨论】:

  • @AlexP。它不起作用!对不起!
  • 你一定是做错了什么。它会在我的系统上生成有效的PNG 文件。和sed 一样 - adb shell screencap -p | sed "s/\r\r$//g" > test.png
  • 也可以试试perl -pe "binmode(STDOUT);s/\r\n/\n/g"
  • @AlexP.:同样的错误; P.S:我在 Windows 7 Pro SP1 x64 和最新的 Android SDK 上使用 Strawberry Perl (64-bit) 5.20.2.1-64bit。
  • 当使用 screencap -p /sdcard/xxx.png 时效果很好。

标签: android windows perl adb screenshot


【解决方案1】:
adb exec-out screencap -p > screen.png

会直接保存在你的机器上

【讨论】:

  • 谢谢,到目前为止最短的答案!
  • 太棒了..穿了
【解决方案2】:

@Passella answer 对我进行了一些调整:

adb shell screencap -p "/mnt/sdcard/output.png" && adb pull "/mnt/sdcard/output.png" "C:\output.png" && adb shell rm "/mnt/sdcard/output.png"

我必须引用路径并将| 替换为&&

另外,如果你使用的是Genymotion模拟器,最好使用自己的adb

C:\"Program Files"\Genymobile\Genymotion\tools\adb shell screencap -p "/mnt/sdcard/output.png" && C:\"Program Files"\Genymobile\Genymotion\tools\adb pull "/mnt/sdcard/output.png" "C:\output.png" && C:\"Program Files"\Genymobile\Genymotion\tools\adb shell rm "/mnt/sdcard/output.png"

【讨论】:

    【解决方案3】:

    试试这个:

    adb shell screencap -p /mnt/sdcard/output.png | adb pull /mnt/sdcard/output.png C:\output.png | adb shell rm /mnt/sdcard/output.png
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-05-31
      • 2012-07-10
      • 1970-01-01
      • 2012-01-20
      • 2013-11-16
      • 1970-01-01
      相关资源
      最近更新 更多