11

I want to automate some stuff on my rooted android Oreo and can't seem to find a way to copy some text to clipboard. I can paste the copied text adb shell input keyevent 279 so hoping to get some way to copy text also.

P.S: not looking for answers suggesting adb shell input text [text] cause it's slow.

GorvGoyl
  • 42,508
  • 29
  • 229
  • 225
  • duplicate of https://stackoverflow.com/q/14243427/1778421 – Alex P. Nov 06 '18 at 15:34
  • I think you want to send some text to clipboard manager of your android device through your desktop and then paste it somewhere in the same android device to make inputting text process faster. Is it what you meant? – royatirek Nov 07 '18 at 12:00
  • no I use shell terminal app to run the commands. and my phone is rooted – GorvGoyl Nov 07 '18 at 12:20

1 Answers1

8

It seems there are 2 ways to copy a text into android clipboard using adb shell.

  1. Using service call clipboard 2 i32 1 i32 0 s16 "text" (Deprecated and doesn't work on android 8)
  2. Using an external service and pass it the text through intent extras. It receives the text then tries to copy it into the clipboard. For example we can install Clipper on the device then run am broadcast -a clipper.set -e text "text" in adb shell.
aminography
  • 21,986
  • 13
  • 70
  • 74
  • For Clipper, it doesn't work well on Android from 10 (? - I'm not sure). We need to do a trick that starts the app before calling get (https://github.com/majido/clipper/issues/9#issuecomment-561631540) – Tuan Chau Dec 04 '19 at 14:01
  • The first way not worked on Android 7 – SuB Aug 24 '23 at 07:35