实例介绍
【实例截图】
这个程序只是测试、说明应用原理的代码,自己根据需要添加动作或脚本。写的匆忙,并未经严格测试,此代码仅供参考。
代码很简单,可自行修改添加。
对于你的设备损害或者损害其他软件的情况自行承担。
代码封装了adb、scrcpy,通过usb链接电脑写脚本操作手机、平板,可用于*音、*手等app软件涮视频赚金币,可以在*音的“全民任务”刷直播间赚。
有很多手机的app(自动点击类的软件)可实现这些功能,但大部分刷金币软件有反外挂机制,不好用甚至有封号风险。
这个程序只是对一台设备的,可以修改一下(就是代码里加个 -s 设备名),可支持多台设备同时进行,电脑USB口够用就行。
写脚本时,可通过“帮助工具”取得点击的屏幕位置,写入脚本。
需要其他更多操作动作的,自行修改代码。
如有问题,留言反馈一下,或 qiaoke_song@163.com。
1、打开设备“开发者模式”然后“允许USB调试”,每种设备不一样,三星、华为、oppo等没啥大问题,经测试,小米还需要关闭一些监控什么的,否则不能进行电脑操作,小米这个查百度解决usb操作问题。
2、安装中文输入的ADBKeyboard.apk时候,有的需要在手机上允许一下,也可直接通过github网站上直接下载到手机安装。
3、执行脚本输入中文时,间隔稍微长一点,2000毫秒左右。这个中文输入还有点小问题,就是有时候不能输入到屏幕,原因是在为了保障原有输入法,本程序判断输入文字是否存在中文,如存在,则切换默认输入法为ADBKeyboard,输入完后恢复为原有输入法,这块代码执行有点问题,再修改吧。注意:脚本里,输入完中文后,需加上一个“点击屏幕”的动作,坐标在屏幕最底部,可以通过本程序的“帮助工具”取得屏幕的坐标位置。如输入英文,则不需安装ADBKeyboard.apk,直接写脚本就可以了。
4、如进入系统出现错误,修改Form1.cs的342行以后的代码,为取得分辨率的,是根据返回字符串截取的,可以直接通过 ADB命令查询字符串后,设置合理的字符串截取规则;
指令:adb shell wm size
5、“帮助工具”不能获取坐标的,先看前一个问题是否正确,再修改phone_tool.cs的423行以下,因为是根据返回字符串截取的,可以直接通过 ADB命令查询字符串后,设置合理的字符串截取规则;如果点击一次没有取得坐标,就多点两次,显示的一直是第一次点击的结果,经测试,每种型号设备的情况略有不同,大部分没有啥问题,谁知道呢。
指令:adb shell getevent -lc 10
本程序使用的一些指令:
public const string GET_NAME = "shell getprop ro.product.name"; // 设备名称public const string GET_DEVICES = "shell getprop ro.product.model"; // 设备
public const string GET_ID = "shell settings get secure android_id"; // 取得id
public const string GET_VERSION = "shell getprop ro.build.version.release"; // 版本
public const string GET_RESOLUTION = "shell wm size"; // 分辨率
public const string GET_IME = "shell ime list -s"; // 获取输入法
public const string GET_ALL_IME = "shell ime list -a"; // 获取输入法
public const string GET_CPU = "shell getprop ro.product.cpu.abi"; // 取得cpu
public const string GET_MEM = "shell cat /proc/meminfo"; // 取得存储信息
public const string GET_BATTEY = " shell dumpsys battery"; // 取得电池信息
public const string GET_PACKAGE = "shell pm list package"; // 安装的应用
public const string GET_DEFAULT_IME = "shell settings get secure default_input_method"; // 取得默认输入法
public const string SET_DEFAULT_CN_IME = "shell settings put secure default_input_method com.android.adbkeyboard/.AdbIME"; // 设置中文输入法
public const string REST_DEFAULT_IME = "shell settings put secure default_input_method"; // 恢复默认输入法
public const string INPUT_CN = "shell am broadcast -a ADB_INPUT_TEXT --es msg"; // 输入中文
public const string INPUT_EN = "shell input text"; // 输入英文
public const string GET_SCREEN_MAX = "shell getevent -lp"; // 取得显示最大范围
public const string GET_GETPRESS = "shell getevent -lc 10"; // 取得点击前10条信息
public const string SET_PRESS = "shell input tap"; // 点击按钮
public const string PRESS_KEY = "shell input keyevent"; // 模拟按键
public const string SET_SWIP = "shell input swipe"; // 模拟划动
取得adb返回的字符串:
public void runADBShell(string shellcommand)
{
CmdStatus = OutputStatus.Busy;
OutputData = string.Empty;
bytesOutputfixed = null;
bytesOutputfixed = Fix0d0d0a(RunAdbProcess(shellcommand));
OutputData = Encoding.ASCII.GetString(bytesOutputfixed).Replace((char)0x0a, ' ');
CmdStatus = OutputStatus.Success;
}
public byte[] Fix0d0d0a(byte[] bytes)
{
long length = bytes.Length;
byte[] bytesfix = new byte[length];
int idx = 0;
int count = 0;
int idxFirst0D = 0;
int idxFirst0A = 0;
bool is0D = false;
for (int i = 0; i < length; i )
{
byte b = bytes[i];
if (b == 0x0d && idxFirst0D == 0)
{
idxFirst0D = i;
is0D = true;
}
if (b == 0x0a && idxFirst0A == 0)
{
idxFirst0A = i;
}
if (i > 2 && b == 0x0a && is0D)
{
count ;
idx = idx - (idxFirst0A - idxFirst0D - 1);
bytesfix[idx] = b;
idx ;
}
else
{
bytesfix[idx] = b;
idx ;
}
if (b == 0x0d)
is0D = true;
else
is0D = false;
}
byte[] bytesfinal = new byte[length - count * (idxFirst0A - idxFirst0D - 1)];
Buffer.BlockCopy(bytesfix, 0, bytesfinal, 0, bytesfinal.Length);
return bytesfinal;
}
【核心代码】
.
├── Android链接Usb操作脚本简易辅助工具.rar
└── Phone_Auxiliary
├── Phone_Auxiliary
│ ├── ADBHelper.cs
│ ├── App.config
│ ├── CrossThreadCall.cs
│ ├── Form1.Designer.cs
│ ├── Form1.cs
│ ├── Phone_Auxiliary.csproj
│ ├── Program.cs
│ ├── Properties
│ │ ├── AssemblyInfo.cs
│ │ ├── Resources.Designer.cs
│ │ ├── Resources.resx
│ │ ├── Settings.Designer.cs
│ │ └── Settings.settings
│ ├── Resource.Designer.cs
│ ├── Resource.resx
│ ├── Resources
│ │ ├── PhoneImg.png
│ │ ├── PhoneLink.png
│ │ ├── background.png
│ │ ├── box.png
│ │ ├── del.png
│ │ ├── m_play.png
│ │ ├── m_stop.png
│ │ ├── open.png
│ │ ├── os.png
│ │ ├── phoneClose.png
│ │ ├── psize.png
│ │ ├── save.png
│ │ ├── spear.png
│ │ ├── spear_Portait.png
│ │ ├── spear_landscape.png
│ │ ├── stop.png
│ │ ├── tback.png
│ │ ├── time.png
│ │ ├── wback.png
│ │ └── winclose.png
│ ├── Serializer.cs
│ ├── Ui
│ │ ├── ConextControl.cs
│ │ ├── ConextForm.cs
│ │ ├── ConextInputBox.cs
│ │ ├── ConextMenu.cs
│ │ ├── ConextSpear.cs
│ │ └── ConextTabControl.cs
│ ├── bin
│ │ ├── Debug
│ │ │ ├── App
│ │ │ │ ├── ADBKeyboard.apk
│ │ │ │ ├── AdbWinApi.dll
│ │ │ │ ├── AdbWinUsbApi.dll
│ │ │ │ ├── SDL2.dll
│ │ │ │ ├── adb.exe
│ │ │ │ ├── avcodec-59.dll
│ │ │ │ ├── avformat-59.dll
│ │ │ │ ├── avutil-57.dll
│ │ │ │ ├── icon.png
│ │ │ │ ├── msys-usb-1.0.dll
│ │ │ │ ├── open_a_terminal_here.bat
│ │ │ │ ├── scrcpy-console.bat
│ │ │ │ ├── scrcpy-noconsole.vbs
│ │ │ │ ├── scrcpy-server
│ │ │ │ ├── scrcpy.exe
│ │ │ │ ├── swresample-4.dll
│ │ │ │ └── swscale-6.dll
│ │ │ ├── Phone_Auxiliary.exe
│ │ │ ├── Phone_Auxiliary.exe.config
│ │ │ └── Phone_Auxiliary.pdb
│ │ └── Release
│ ├── obj
│ │ └── Debug
│ ├── phone_command.cs
│ ├── phone_global.cs
│ ├── phone_info.cs
│ ├── phone_screen.cs
│ ├── phone_script.cs
│ └── phone_tool.cs
└── Phone_Auxiliary.sln
11 directories, 69 files
小贴士
感谢您为本站写下的评论,您的评论对其它用户来说具有重要的参考价值,所以请认真填写。
- 类似“顶”、“沙发”之类没有营养的文字,对勤劳贡献的楼主来说是令人沮丧的反馈信息。
- 相信您也不想看到一排文字/表情墙,所以请不要反馈意义不大的重复字符,也请尽量不要纯表情的回复。
- 提问之前请再仔细看一遍楼主的说明,或许是您遗漏了。
- 请勿到处挖坑绊人、招贴广告。既占空间让人厌烦,又没人会搭理,于人于己都无利。
关于好例子网
本站旨在为广大IT学习爱好者提供一个非营利性互相学习交流分享平台。本站所有资源都可以被免费获取学习研究。本站资源来自网友分享,对搜索内容的合法性不具有预见性、识别性、控制性,仅供学习研究,请务必在下载后24小时内给予删除,不得用于其他任何用途,否则后果自负。基于互联网的特殊性,平台无法对用户传输的作品、信息、内容的权属或合法性、安全性、合规性、真实性、科学性、完整权、有效性等进行实质审查;无论平台是否已进行审查,用户均应自行承担因其传输的作品、信息、内容而可能或已经产生的侵权或权属纠纷等法律责任。本站所有资源不代表本站的观点或立场,基于网友分享,根据中国法律《信息网络传播权保护条例》第二十二与二十三条之规定,若资源存在侵权或相关问题请联系本站客服人员,点此联系我们。关于更多版权及免责申明参见 版权及免责申明
网友评论
我要评论