如何确定softkeyboard是否显示在屏幕上

如何确定softkeyboard是否显示在屏幕上

本文介绍了如何确定softkeyboard是否显示在屏幕上 - 而使用monkeyrunner的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图自动化几屏的点击和使用monkeyrunner项(使用AndroidViewClient)

I am trying to automate few screen clicks and entries using monkeyrunner(using AndroidViewClient )

每当有在屏幕上的EditText,软键盘弹出,如果我想preSS虽然findViewById一个按钮,(假设这个特殊的按钮是软键盘后面)失败。相反,点击这个按钮,点击它在软键盘按钮一些。因此,作为一个变通,我需要preSS背透猴亚军键,隐藏软键盘。

Whenever there is a edittext in the screen, the soft keyboard is popping up, and if I want to press a button though findViewById, (assuming that this particular button is behind the soft keyboard) fails. Instead of clicking this button, it clicks on some button in the soft keyboard. So as a work around I need to press back key through monkey runner, to hide the soft keyboard.

我的问题是如何确定是否显示在屏幕软键盘或不是从monkeyrunner运行时。

My question is how to determine whether soft keyboard is shown in the screen or not while running from monkeyrunner.

当我看着logcat中,我看到这个以下,同时显示了软键盘

When I looked at the logcat, I see this following while showing up the soft keyboard

I/SurfaceFlinger( 2045): id=143(28) createSurf 0x4326743c (720x593),1 flag=0, InputMethod

和显示此同时softkeyboard被删除

and displays this while softkeyboard is removed

I/SurfaceFlinger( 2045): id=142 Removed InputMethod idx=4 MapSz=3
I/SurfaceFlinger( 2045): id=142 Removed InputMethod idx=-2 MapSz=3

如果有人能提供如何解析从monkeyrunner脚本的logcat输出ADB一个例子,我可以使用作为最后的选择,如果有发现任何合适的替代解决方案。

If someone can provide an example of how to parse the adb logcat output from the monkeyrunner script, I can use that as a last option, if there is any suitable alternative solution found.

推荐答案

你在答复中提到什么能成为一个伟大的除了的,我会尽力尽快融入它。

What you mentioned in your answer could be a great addition to AndroidViewClient and I'll try to incorporate it soon.

反正有得到同样的信息,但在一个更加错综复杂的方式的方法,包括:

Anyway, there is a method of getting the same info, though in a more convoluted way:

...
from com.dtmilano.android.viewclient import ViewClient

vc = ViewClient(*ViewClient.connectToDeviceOrExit())
view = vc.findViewByIdOrRaise('id/no_id/1')
view.getXY() # getXY() calls __dumpsWindowsInformation()
for w in view.windows:
    if view.windows[w].activity == 'InputMethod':
        print view.windows[w].visibility

11-FEB-15

更新

最新AndroidViewClient /库莱布拉版本的支持 isKeyboardShown()方法。使用这样的:

Update on 11-FEB-15

Latest AndroidViewClient/culebra versions support isKeyboardShown() method. Use like this:

#! /usr/bin/env python
# -*- coding: utf-8 -*-
'''
Copyright (C) 2013-2014  Diego Torres Milano
Created on 2015-02-11 by Culebra v10.0.8
                      __    __    __    __
                     /  \  /  \  /  \  /  \
____________________/  __\/  __\/  __\/  __\_____________________________
___________________/  /__/  /__/  /__/  /________________________________
                   | / \   / \   / \   / \   \___
                   |/   \_/   \_/   \_/   \    o \
                                           \_____/--<
@author: Diego Torres Milano
@author: Jennifer E. Swofford (ascii art snake)
'''


import re
import sys
import os


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

from com.dtmilano.android.viewclient import ViewClient

TAG = 'CULEBRA'

_s = 5
_v = '--verbose' in sys.argv


kwargs1 = {'ignoreversioncheck': False, 'verbose': False, 'ignoresecuredevice': False}
device, serialno = ViewClient.connectToDeviceOrExit(**kwargs1)
print "Is keyboard shown:", device.isKeyboardShown()

这篇关于如何确定softkeyboard是否显示在屏幕上 - 而使用monkeyrunner的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-31 09:55