adb 命令 pc端 "复制粘贴" 文本到android设备

假如你像我一样在寻找android下通过命令复制粘贴的方法。
不过android上是没有直接进行复制粘贴剪切板的命令,只有间接实现:

1、android设备

首先android设备上,要把光标焦点定位到需要输入的文本框,比如当你输入用户名密码的时候

2、PC端

电脑上adb连接好android设备
cmd 命令行
1、adb shell input text hell0
则hello自动的填到获得焦点的输入框了
2、adb shell input keyevent 61
输入tab键定位到下一输入框,
tab键的key code是61 --> "KEYCODE_TAB"
adb shell input keyevent 61
adb shell input keyevent 3
adb shell input keyevent 82
具体数值 看android源码 android.view.KeyEvent.java
KEYCODE列表
3、input的命令

C:\Users\Administrator>adb shell input help
Error: Unknown command: help
usage: input ...
       input text <string>
       input keyevent <key code number or name>
       input [touchscreen|touchpad] tap <x> <y>
       input [touchscreen|touchpad] swipe <x1> <y1> <x2
       input trackball press
       input trackball roll <dx> <dy>


作者:proud2008
链接:https://www.jianshu.com/p/d818290f70e5/
来源:简书
简书著作权归作者所有,任何形式的转载都请联系作者获得授权并注明出处。
posted @ 2021-11-20 09:50  左正  阅读(1685)  评论(0编辑  收藏  举报