Skip to content

Instantly share code, notes, and snippets.

@ssddi456
Created November 19, 2019 06:19
Show Gist options
  • Save ssddi456/889d5e8a2571a33e8fcd0ff6f1288291 to your computer and use it in GitHub Desktop.
Save ssddi456/889d5e8a2571a33e8fcd0ff6f1288291 to your computer and use it in GitHub Desktop.
adbpaste

script to send your clipbroad content to android input on windows,

based on great tiny tool ADBKeyBoard

you can get the app from F-Droid.

@echo off
powershell -sta -F %~dp0/adbpaste.ps1
add-type -as System.Windows.Forms;
$content = [windows.forms.clipboard]::GetText();
$origin_ime = adb.exe shell ime list -s
adb.exe shell ime set com.android.adbkeyboard/.AdbIME
echo $content
$Bytes = [System.Text.Encoding]::Unicode.GetBytes($content)
$EncodedText = [Convert]::ToBase64String($Bytes)
echo $EncodedText
adb shell am broadcast -a ADB_INPUT_B64 --es msg `"$EncodedText`"
adb.exe shell ime set $origin_ime
@sunshinewithmoonlight
Copy link

sunshinewithmoonlight commented May 23, 2020

Hello, I have a python script that implements the same function as your ps script. :3

import os
import base64

# os.system("adb devices")

chars = '的广告'
charsb64 = str(base64.b64encode(chars.encode('utf-8')))[1:]
# print(charsb64)

os.system("adb shell am broadcast -a ADB_INPUT_B64 --es msg %s" %charsb64)

Thanks to https://stackoverflow.com/questions/33294213/how-to-decode-unicode-in-a-chinese-text

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment