清除编辑文字-ADB [英] Clear Edit Text - adb

查看:1549
本文介绍了清除编辑文字-ADB的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何使用shell命令清除焦点编辑文本。

How to clear focused Edit text using shell command.

我尝试了

adb shell input keyevent KEYCODE_CLEAR // Not worked 
adb shell input keyevent KEYCODE_DEL // Delete only one char
adb shell input keyevent KEYCODE_FORWARD_DEL // Not worked

通过此操作,我只能删除最多一个字符,有什么办法可以删除/清除重点突出的编辑文本。

With this I am only able to delete upto One character only, Is there any way I can delete/clear the focused Edit text.

推荐答案

这对我有用:

function clear_input() {
    adb shell input keyevent KEYCODE_MOVE_END
    adb shell input keyevent --longpress $(printf 'KEYCODE_DEL %.0s' {1..250})
}

然后:

clear_input

这篇关于清除编辑文字-ADB的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆