ADBKeyBoard 安装 (中文输入)
问题:
adb shell input text '你好嗎'
is not going to work.
ADBKeyboard 在这些情况下会有所帮助,尤其是在设备自动化和测试中
1. 下载
github网址:https://github.com/senzhk/ADBKeyBoard?tab=readme-ov-file
apk下载:
https://github.com/senzhk/ADBKeyBoard/blob/master/ADBKeyboard.apk
将下载好的apk放置在cmd命令同一个文件夹中,同时手机开启权限,可通过adb安装应用
2. 安装
安装命令:
adb install ADBKeyboard.apk
设置手机输入法
adb shell ime enable com.android.adbkeyboard/.AdbIME
adb shell ime set com.android.adbkeyboard/.AdbIME
3.示例
使用案例
import os
import base64
chars = "你好"
charsb64 = str(base64.b64encode(chars.encode("utf-8")))[1:]
os.system("adb shell am broadcast -a ADB_INPUT_B64 --es msg %s" % charsb64)
测试完成,返回原先的输入法:
原先输入法为:com.baidu.input_mi/.ImeService
adb shell ime set com.baidu.input_mi/.ImeService
其他命令
adb shell ime list -a # Check your available virtual keyboards
adb shell ime reset # Reset to default, don't care which keyboard was chosen before switch