Skip to content

Instantly share code, notes, and snippets.

@zhangtaii
Last active March 3, 2021 17:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zhangtaii/9e205ff1e6bdcd50568befe633c4b5df to your computer and use it in GitHub Desktop.
Save zhangtaii/9e205ff1e6bdcd50568befe633c4b5df to your computer and use it in GitHub Desktop.
adb_split_input.js
#!/usr/bin/env node
// usage: ./adb_input.js yourtext
const util = require('util');
const exec = util.promisify(require('child_process').exec);
async function execAsync(cmd) {
try {
const { stdout, stderr } = await exec(cmd);
console.log('stdout:', stdout);
console.log('stderr:', stderr);
} catch (e) {
console.error(e);
}
}
async function main() {
const args = process.argv.slice(2);
const input = args[0];
const inputArray = input.split('');
for (var i = 0; i < inputArray.length; i++) {
const char = inputArray[i];
// const cmd = 'adb shell input text ' + '"' + inputArray[i] + '"'
const cmd = `adb shell input text "${inputArray[i]}"`
console.log(cmd);
await execAsync(cmd);
}
}
main();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment