我遇到了一个奇怪的问题,从命令行运行adb shell sendevent x x x命令很好,但是当我使用以下任何一个命令时:
subprocess.Popen(['adb', 'shell', 'sendevent', 'x', 'x','x'])
subprocess.Popen('adb shell sendevent x x x', shell=True)
subprocess.call(['adb', 'shell', 'sendevent', 'x', 'x','x'])
它们都失败了--即使是在shell脚本中工作的模拟触摸,在通过python调用时也不能正常工作。此外,我尝试将外壳脚本adb push到设备,并使用adb shell /system/sh /sdcard/script.sh成功地运行了它,但是当我试图通过python运行命令行时,脚本失败了。
更奇怪的是,他运行的脚本,但例如,它似乎没有执行命令sleep 1中途脚本,echo命令工作,sendevent命令似乎不起作用。
看上去都不可能,但就是这样。如何通过python运行一组adb shell sendevent x x x命令?
发布于 2013-08-23 17:01:33
sendevent采用4个参数args for Popen应该是['adb', 'shell', 'sendevent /dev/input/eventX type code value'] --不要拆分远程命令sendevent序列来说,定时是很重要的,而adb shell调用本身也是很昂贵的,所以在设备上使用shell脚本会更好。\n而不是\r\n)https://stackoverflow.com/questions/18407470
复制相似问题