繁体   English   中英

python 和 (android) adb shell

[英]python and (android) adb shell

我想使用“adb shell tap xy”功能(或您可能知道的任何其他方式)通过我计算机上的python代码模拟我的anroid手机上的触摸。 我试过使用

from subprocess import call
call(["adb", "kill-server"])
call(["adb", "shell"])
call(["input", "tap" , "1400" , "800"]) //example of x and y

但它刚刚到达“shell”调用并卡住了。 (我知道 tap 功能有效,因为它适用于普通的 cmd 窗口)

这应该这样做:

from subprocess import call
call(["adb", "shell", "input", "tap" , "1400" , "800"])

在您的原始脚本中:

  1. 您在 Android 设备上启动远程 shell ( adb shell )
  2. 键入exit退出远程外壳后,您在主机外壳上发出命令( input tap 1400 800 )。

相反,您应该使用 adb 将命令重定向到 Android 设备的远程 shell。 为此,只需在adb shell之后附加命令,例如adb shell input tap 1400 800 看看这里

我还删除了adb kill-process行,因为没有kill-process adb 命令。

现在,您可以直接使用python adb接口https://pypi.org/project/pure-python-adb/发送您的Shell命令。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM