# 使用 adb 启用 ADBKeyBoard
adb shell ime enable com.android.adbkeyboard/.AdbIME
# 切换 ADBKeyBoard 虚拟键盘
adb shell ime set com.android.adbkeyboard/.AdbIME
# 切换回原始虚拟键盘
adb shell ime set com.nuance.swype.dtc/com.nuance.swype.input.IME
# adb shell ime set com.baidu.input_huawei/.ImeService
# 显示可用的虚拟键盘
adb shell ime list -a
# 重置虚拟键盘
adb shell ime reset
# 1.Sending text input (base64) if (1) is not working.
# * For Mac/Linux, you can use the latest base64 input type with base64 command line tool:
adb shell am broadcast -a ADB_INPUT_B64 --es msg `echo -n '你好嗎? Hello?' | base64`
# * Sample python script to send b64 codes (provided by sunshinewithmoonlight):
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)
# 2. Sending keyevent code (67 = KEYCODE_DEL)
adb shell am broadcast -a ADB_INPUT_CODE --ei code 67
# 3. Sending editor action (2 = IME_ACTION_GO)
adb shell am broadcast -a ADB_EDITOR_CODE --ei code 2
# 4. Sending unicode characters
To send Cat
adb shell am broadcast -a ADB_INPUT_CHARS --eia chars '128568,32,67,97,116'
# 5. Send meta keys
# To send Ctrl + A as below: (4096 is META_CONTROL_ON, 8192 is META_CONTROL_LEFT_ON, 29 is KEYCODE_A)
adb shell am broadcast -a ADB_INPUT_TEXT --es mcode '4096,29' // one metaState.
# or
adb shell am broadcast -a ADB_INPUT_TEXT --es mcode '4096^+^8192,29' // two metaState.
# To send Ctrl + V , 实现粘贴
adb shell am broadcast -a ADB_INPUT_TEXT --es mcode '4096,50'
# 6. CLEAR all text (starting from v2.0)
adb shell am broadcast -a ADB_CLEAR_TEXT
$str=[Convert]::ToBase64String([Text.Encoding]::UTF8.GetBytes("欢迎大家访问作者技术站点【https://weiyigeek.top】"))
adb shell am broadcast -a ADB_INPUT_B64 --es msg $msg