adb 命令记录

def getXY(self, driver):
cmd = 'C:\\Users\\test\\Desktop\\test\\adt\\sdk\\platform-tools\\adb.exe -s {0} shell getevent'.format(self.desired_caps['deviceName']) # 通过点击事件识别 (0035 X 0036 Y)
p = subprocess.Popen(cmd, stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
stdin=subprocess.PIPE, shell=True)
l = []
while 1:
line = p.stdout.readline().decode()
if len(l) == 2:
break
if '0035' in line or '0036' in line:

l.append(line.split(' ')[-1])
  
# .\adb.exe -s 9462156 shell getevent -p 得到 x max y max 分辨率分别除以 xmax ymax 等到换算比例


width = HEX.get(l[0].strip()[-2], 0) * 16 + HEX.get(l[0].strip()[-3], 0) * 16 * 16 + HEX.get(l[0].strip()[-1],
0) # 换算比例是1 所以不用乘
height = HEX.get(l[1].strip()[-2], 0) * 16 + HEX.get(l[1].strip()[-3], 0) * 16 * 16 + HEX.get(l[1].strip()[-1],
0)
return(width, height)

posted on 2018-03-05 18:38  0o0o0o0o0o000  阅读(122)  评论(0编辑  收藏  举报

导航