Reputation: 169
i would like to simulate touch on my anroid phone through a python code on my computer using the "adb shell tap x y" function (or any other way you may know). I have tried using
from subprocess import call
call(["adb", "kill-server"])
call(["adb", "shell"])
call(["input", "tap" , "1400" , "800"]) //example of x and y
but it just reaches the "shell" call and gets stuck. (I know the tap function works because it works on the ordinary cmd window)
Upvotes: 1
Views: 4325
Reputation: 3562
This should do it:
from subprocess import call
call(["adb", "shell", "input", "tap" , "1400" , "800"])
In your original script:
adb shell
)exit
, you issue a command on your host computer shell (input tap 1400 800
). Instead you should use adb to redirect a command to the Android device's remote shell. To do that, just append the command after adb shell
, for example adb shell input tap 1400 800
. Take a look here.
I also removed the adb kill-process
line because there is no kill-process
adb command.
Upvotes: 2