commit 63459fdc40cd7161d301fe3f7f93e61c6a8cd5e2 Author: 编码猿 Date: Fri Sep 27 01:26:21 2024 +0800 first commit diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..403adbc --- /dev/null +++ b/.gitignore @@ -0,0 +1,23 @@ +.DS_Store +node_modules +/dist + + +# local env files +.env.local +.env.*.local + +# Log files +npm-debug.log* +yarn-debug.log* +yarn-error.log* +pnpm-debug.log* + +# Editor directories and files +.idea +.vscode +*.suo +*.ntvs* +*.njsproj +*.sln +*.sw? diff --git a/.pydio b/.pydio new file mode 100644 index 0000000..118d709 --- /dev/null +++ b/.pydio @@ -0,0 +1 @@ +0bf40545-e6e5-4371-b0fe-6e41a7e2fbda \ No newline at end of file diff --git a/ADBKeyboard.apk b/ADBKeyboard.apk new file mode 100644 index 0000000..2483dd0 Binary files /dev/null and b/ADBKeyboard.apk differ diff --git a/README.md b/README.md new file mode 100644 index 0000000..d551264 --- /dev/null +++ b/README.md @@ -0,0 +1,15 @@ +https://github.com/senzhk/ADBKeyBoard + +1:adb shell input tap 985 1213 点击点赞 +2:adb shell input swipe 271 1733 208 516 从底部坐标滑到顶部坐标,滑动切换视频 + +adb shell input tap 149 552 从桌面打开抖音App的坐标 +adb shell input tap 992 1460 点击评论图标,打开评论弹窗 +adb shell input tap 347 2175 点击输入框,获得输入框焦点 + +adb shell input text test(废弃) 在输入框输入文字(不支持中文) + +adb shell am broadcast -a ADB_INPUT_TEXT --es msg '随机评论的中文字' +adb shell input tap 1007 1854 点击发送按钮 + +//package:com.android.adbkeyboard \ No newline at end of file diff --git a/config/.pydio b/config/.pydio new file mode 100644 index 0000000..e33e0be --- /dev/null +++ b/config/.pydio @@ -0,0 +1 @@ +fc3940ae-ad6b-4e14-945c-7d3b195ddf08 \ No newline at end of file diff --git a/config/index.js b/config/index.js new file mode 100644 index 0000000..864fb06 --- /dev/null +++ b/config/index.js @@ -0,0 +1,27 @@ +const config = { + // 基础命令 + baseShell: { + adbkeyboard: 'adb shell pm list packages adbkeyboard', + adb: 'adb version' + }, + // 功能性命令 + shellAction: { + // 点击输入框 + tap: 'adb shell input tap', + // 滑动页面 + swipe: 'adb shell input swipe', + }, + // 坐标集合 + shellCoordinate: { + // 先点赞,然后滑动下一个视频 + Fabulous: { + tap: '988 1229', // 点赞按钮的坐标 + swipe: '868 1811 800 272', // 滑动页面 + } + }, + startShell: (action, coordinate) => { + return `${config.shellAction[action]} ${coordinate}` + } +} + +module.exports = config \ No newline at end of file diff --git a/index.js b/index.js new file mode 100644 index 0000000..86d289d --- /dev/null +++ b/index.js @@ -0,0 +1,14 @@ +const config = require("./config"); +const utils= require("./utils"); + +for (const key in config.shellCoordinate.Fabulous) { + let shell = config.startShell(key, config.shellCoordinate.Fabulous[key]) + console.log(shell) + setInterval(async ()=> { + console.log(await utils.execShell(shell)) + },1500) +} + +// utils.CheckInstallAdb().then(res => { +// console.log(res) +// }) \ No newline at end of file diff --git a/shell/.pydio b/shell/.pydio new file mode 100644 index 0000000..af3bc4c --- /dev/null +++ b/shell/.pydio @@ -0,0 +1 @@ +4f3298b7-6a94-46ec-928b-7ba7afe08f60 \ No newline at end of file diff --git a/shell/comment.sh b/shell/comment.sh new file mode 100755 index 0000000..f4860b6 --- /dev/null +++ b/shell/comment.sh @@ -0,0 +1,2 @@ +#!/bin/bash +echo "你好" \ No newline at end of file diff --git a/test.js b/test.js new file mode 100644 index 0000000..a16612e --- /dev/null +++ b/test.js @@ -0,0 +1,8 @@ +const exec = require('child_process').exec; +exec('pwd', function(err,stdout,stderr) { + if(err) { + console.log('shell is run: '+ stderr); + } else { + console.log(stdout) + } +}); \ No newline at end of file diff --git a/utils/.pydio b/utils/.pydio new file mode 100644 index 0000000..3cfafd7 --- /dev/null +++ b/utils/.pydio @@ -0,0 +1 @@ +358a802d-b623-4739-bde0-48834194aec5 \ No newline at end of file diff --git a/utils/index.js b/utils/index.js new file mode 100644 index 0000000..9bdd541 --- /dev/null +++ b/utils/index.js @@ -0,0 +1,55 @@ +const exec = require('child_process').exec; +const config = require('../config'); + +class Utils{ + + /** + * 运行命令 + * @param cmdStr + * @returns {Promise} + */ + execShell (cmdStr) { + return new Promise((resolve,reject)=> { + exec(cmdStr, function(err,stdout,stderr) { + if(err) { + console.log('shell is run: '+ stderr); + } else { + resolve(stdout) + } + }); + }) + } + + /** + * 检查是否安装 ADBKeyboard.apk app + * 否则无法输入中文 + * @constructor + */ + async CheckAdbKeyboard() { + let res = await this.execShell(config.baseShell.adbkeyboard); + if (res.indexOf("com.android.adbkeyboard") > -1) { + return true + } else { + console.error("请先安装 ADBKeyboard.apk") + return false + } + } + + /** + * 检查是否安装adb + * @returns {Promise} + * @constructor + */ + async CheckInstallAdb() { + let res = await this.execShell(config.baseShell.adb) + if (res.indexOf("Android Debug Bridge version") > -1) { + return true + } else { + console.error("请先在PC电脑上安装adb工具!!") + return false + } + } + +} + +module.exports = new Utils(); \ No newline at end of file