---
title: "ubuntu linux通过adb命令行\"复制粘贴\"内容到android"
author: "vfate_linux"
date: "2014-08-07T11:28:29Z"
tags: []
categories: ["行业应用"]
slug: "ubuntu-linux-adb-android"
draft: false
lastmod: "2014-08-07T11:28:29Z"
id: 2101250
url: "https://govfate.iteye.com/blog/2101250"
---

假如你像我一样在寻找android下通过命令复制粘贴的方法,来对地方了,不过android上是没有直接进行复制粘贴剪切板的命令,只有间接实现:在电脑上直接adb输入信息到android设备上

首先android设备上,要把光标焦点定位到需要输入的文本框,比如当你输入用户名密码的时候
电脑上adb连接好android设备
电脑上执行adb命令如下,比如你的用户名是hello,密码是world

```shell
adb shell input text hello
#输入tab键定位到下一输入框,tab键的key code是61 --> "KEYCODE_TAB" 
adb shell input keyevent 61
#然后输入密码
adb shell input text world
#回车确认登录,回车键的key code是66
adb shell input keyevent 66

```


扩展阅读,假如你的密码比较复杂有但引号之类,比如为 wor"ld

```shell
adb shell input text wor\\\"ld
```


参考:<http://blog.rungeek.com/post/42456936947/sending-keyboard-input-via-adb-to-your-android-device>