1

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)

1

1 Answer 1

2

This should do it:

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

In your original script:

  1. You start a remote shell on your Android device (adb shell)
  2. After you quit the remote shell typing 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.

Sign up to request clarification or add additional context in comments.

1 Comment

No problem :-) If the answer helped you, consider upvoting and accepting it, so to help other people in the future.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.