Last active
March 3, 2021 17:11
-
-
Save zhangtaii/9e205ff1e6bdcd50568befe633c4b5df to your computer and use it in GitHub Desktop.
adb_split_input.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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