2017-07-11 93 views
3

如何用“某些文字”使用adb shell input text这样的空格发送文字?adb shell输入带空格的文本

实测值以下溶液

adb shell input text "some%stext"工作正常。 但是用%s替换空间的简单方法是什么?

例子:

$ adb shell input text "some text" 
Error: Invalid arguments for command: text 
Usage: input [<source>] <command> [<arg>...] 

The sources are: 
     keyboard 
     mouse 
     joystick 
     touchnavigation 
     touchpad 
     trackball 
     dpad 
     stylus 
     gamepad 
     touchscreen 

The commands and default sources are: 
     text <string> (Default: touchscreen) 
     keyevent [--longpress] <key code number or name> ... (Default: keyboard) 
     tap <x> <y> (Default: touchscreen) 
     swipe <x1> <y1> <x2> <y2> [duration(ms)] (Default: touchscreen) 
     press (Default: trackball) 
     roll <dx> <dy> (Default: trackball) 

回答

2

使用GNU Linux的 - sed的安装(大多数Linux机器提供它预装) - 你可以用sed来替换%s的空间。

adb shell input text $(echo "some text with spaces" | sed -e 's/ /\%s/g') 

%-sign必须用\转义。

0

你可以把你的文字,如:

文本= “一些文字用空格”

替换为相思%S

- >

adb shell input text some%stext%swith%sspaces