最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

autohotkey - Using AHK v1 to save a screenshot from adb (redirect binary output to a file) - Stack Overflow

programmeradmin4浏览0评论

In an AHK script, I'm trying to redirect the binary output from adb to a file. adb exec-out screencap -p > Screenshot.png However, it looks like AHK's RunWait doesn't really handle binary output.

How can I make this work?

I've toyed around with StdoutToVar and CMDRet, but don't really know what I'm doing.

In an AHK script, I'm trying to redirect the binary output from adb to a file. adb exec-out screencap -p > Screenshot.png However, it looks like AHK's RunWait doesn't really handle binary output.

How can I make this work?

I've toyed around with StdoutToVar and CMDRet, but don't really know what I'm doing.

Share Improve this question asked Mar 22 at 20:53 hoytdjhoytdj 1643 silver badges14 bronze badges 3
  • 1 Redirecting stdout via greater sign in a command is handled by the command interpreter like cmd.ese. Thus you may want to execute the ad command in cmd.exe instead of AHK itself, then redirection will also work. cmd.exe /c adb exec-out ... > Screenshot.png You may need to do some experiments to find the correct quoting for the redirect to screenshot.png part to be executed on PC side in cmd. – Robert Commented Mar 23 at 0:04
  • @Robert That's what I've been doing. runWait, %ComSpec% /c adb exec-out screencap -p > Screenshot.png. When I run the same command directly in the windows terminal, it works fine. When I run it via runWait, the file is corrupt. – hoytdj Commented Mar 23 at 2:05
  • Never mind, you're right. It was just a quoting issue. After playing around for way to long with Gdip functions, I ended up just needing an extra set of quotes around %command% – hoytdj Commented Mar 23 at 2:15
Add a comment  | 

1 Answer 1

Reset to default 0

As Robert suggest it was just a matter of properly quoting. Here's what ended up working.

command := """" . adbPath . """ -s " . deviceAddress . " exec-out screencap -p > """ .  outputFile . """"
RunWait, %ComSpec% /c "%command%", , Hide
发布评论

评论列表(0)

  1. 暂无评论