【问题标题】:python and (android) adb shell蟒蛇和(安卓)亚行外壳
【发布时间】:2015-12-06 17:38:02
【问题描述】:

我想使用“adb shell tap x y”函数(或您可能知道的任何其他方式)通过我计算机上的 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 窗口)

【问题讨论】:

标签: android python shell cmd adb


【解决方案1】:

应该这样做:

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

在您的原始脚本中:

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

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

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

【讨论】:

  • 没问题 :-) 如果答案对您有帮助,请考虑支持并接受它,以便将来帮助其他人。
猜你喜欢
  • 1970-01-01
  • 2014-09-22
  • 2016-01-31
  • 2021-10-21
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2019-01-08
  • 2017-08-30
相关资源
最近更新 更多