2015-12-06 34 views
0

我想通過使用「亞行外殼自來水x和y」功能(或者你可以知道任何其他方式)我的計算機上的Python代碼來模擬我的Anroid的手機上的觸摸。我試過使用Python和(機器人)亞行外殼

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

但它只是到達「殼」的電話,並卡住了。 (我知道Tap功能的作品,因爲它的工作原理普通CMD窗口)

+0

http://ktnr74.blogspot.com/2013/06/emulating-touchscreen-interaction-with.html –

回答

1

這應做到:

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

在原來的腳本:

  1. 你上啓動一個遠程shell您的Android設備(adb shell
  2. 在您退出遠程外殼並鍵入exit之後,您在主機外殼(input tap 1400 800)上發出命令。

相反,您應該使用adb將命令重定向到Android設備的遠程shell。要做到這一點,adb shell後只是追加的命令,例如adb shell input tap 1400 800。看看here

我也去掉了adb kill-process線,因爲沒有kill-process ADB命令。

+0

或右邊是殺的服務器,並感謝您! –

+0

:-)如果答案幫你,考慮upvoting並接受它,所以要幫助其他人在未來沒有問題。 –