AdbPaste
AdbPaste copied to clipboard
uses the Android adb tool to send input. StdIn will be massaged to go trhu all the hops adb uses unchanged. Require python, but after that, it's as cross-platform as it goes, while using adb directly,...
AdbPaste
uses the Android adb tool to send input. StdIn will be massaged to go trhu all the hops adb uses unchanged. Require python, but after that, it's as cross-platform as it goes, while using adb directly, you will have problems like not being able to send spaces in windows.
Usage
--help,-h Show usage information
--notab Changes tabs into single spaces
-s Serial number of the device adb should use. Analogous to -s flag of adb (use adb devices
to see a list). Only needed if more than one device are available.
--file Next argument must be a filename. Content will be sent.
If --file is not used, all the next arguments will be sent. If no arguments are passed, input is read from stdin.
the problem
Can not use spaces in win32. Even with escaping.
C:\CODE\AdbPaste>adb shell input text "simple test"
Error: Invalid arguments for command: text
usage: input ...
input text <string>
input keyevent <key code number or name>
input [touchscreen|touchpad|touchnavigation] tap <x> <y>
input [touchscreen|touchpad|touchnavigation] swipe <x1> <y1> <x2> <y2> [d
uration(ms)]
input trackball press
input trackball roll <dx> <dy>
More on the above: https://web.archive.org/web/20210724065902/https://www.wietzebeukema.nl/blog/windows-command-line-obfuscation
Can not use bash keywords (i am sure i am using the word wrongly here), without escaping.
C:\CODE\AdbPaste>adb shell input text "simple("
/system/bin/sh: syntax error: '(' unexpected
Can not send a huge string as the emulator timesout and drop much of it.
Common solution to use a SMS and copy/paste is faster on an actual device, but less practical for running automated tests in the emulator. On automated tests it is easier to wait a few seconds than to deal with application switching and copy paste.
Solution
Converts all characters into hexadecimal interpretation using the bash $'\x00'
string literal format. Additionally splits the string on %
to prevent adb shell input
from replacing %s
by spaces.