0

出于某种原因,无论我做什么,我都无法使用 AndroidViewClient 向我的外部 android 设备发出“拖动”命令。这是我的代码:

import sys
import os
import time

try:
    sys.path.append(os.path.join(os.environ['ANDROID_VIEW_CLIENT_HOME'], 'src'))
except:
    pass

from com.dtmilano.android.adb.adbclient import AdbClient
from com.dtmilano.android.viewclient import ViewClient, View

print 'Connecting to device...'
device, serialno = ViewClient.connectToDeviceOrExit()

 time.sleep(.5)
 AdbClient(serialno='.*').drag((500,1000),(500,100), 1, 10)

我也试过

device.drag((500,1000),(500,100), 1, 10)

这也不起作用。(顺便说一句,device.drag() 与 AdbClient.drag() 有何不同?)

另外,我没有从上面得到任何错误。一切运行,没有发现错误。它只是不拖动屏幕。

然而,触摸事件和键盘事件有效:

device.touch(400,200, 'DOWN_AND_UP')

注意:我的 AndroidViewCLient 版本是 7.0.2。我的安卓设备是 Jellybean 4.1

编辑:我的 android 设备的输出:

C:\Users\Me>adb shell input
usage: input ...
       input text <string>
       input keyevent <key code number or name>
       input tap <x> <y>
       input swipe <x1> <y1> <x2> <y2>
4

1 回答 1

2

我发现了问题。当AdbClient获取 API 级别(版本)时,它不会转换为,int因此比较AdbClient.drag()失败,因为它是一个字符串,并且错误的命令被发送到 API 16。这个:

__send(shell:input touchscreen swipe 500 400 100 400 1, checkok=True, reconnect=False)

代替

__send(shell:input swipe 500 400 100 400, checkok=True, reconnect=False)

它将在 AVC 7.0.4 中修复。

于 2014-06-06T19:54:18.967 回答