.NET开发一个微信跳一跳辅助程序

昨天微信更新了,出现了一个小游戏“跳一跳”,玩了一下 赶忙还蛮有意思的 但纯粹是拼手感的,玩了很久,终于搞了个135分拿了个第一名,没想到过一会就被朋友刷下去了,最高的也就200来分把,因而就想着要是开发个辅助就行了,因而简单想了一下最高游戏shell

先来讲下这个游戏的界面和规则:微信

先看看界面ide

规则:按住屏幕 按必定时间松开就能够跳跃,跳跃到前方的图案中得1分,图按中间得2分(连续多个中间累加2分,好比第一个2分 第二个4分 第三个6分 最高累计32分) 其它规则不说明了函数

整理了下实现原理,其实挺简单的:就是计算黑人的底部到图案中间的距离,而后就调试时间,调好时间后就计算一个像素点的最佳时间X,而后之后每次测试黑人底部到图案中心的距离*X 就是最佳时间测试

理论知识好了 就来实践把spa

一、首先要获取手机屏幕的图片 并展现在winform程序里面
二、让客户点击黑人底部和图案中心点(根据图片去获取这两个点 貌似有点困难 至少我如今的技术困难)3d

三、模拟屏幕按下并按住多长时间调试

获取屏幕图片咱们能够根据安卓的adb.exe来获取,但我对这个东西不太熟悉,就百度了几个命令  一、截屏命令 2 传输命令 和模拟滑动命令code

adb shell /system/bin/screencap -p /sdcard/screenshot.png(保存到SDCard)
adb pull /sdcard/screenshot.png d:/screenshot.png(保存到电脑)
adb shell input swipe 250 250 300 300 100 滑动 前四个是坐标 最后一个是时间

好了实现的方法也找到了 就码代码把orm

执行adb命令的函数

 1 /// <summary>
 2         /// 执行adb命令
 3         /// </summary>
 4         /// <param name="arguments"></param>
 5         /// <param name="ischeck"></param>
 6         /// <returns></returns>
 7         private string cmdAdb(string arguments,bool ischeck=true)
 8         {
 9             if (ischeck&&!HasAndroid)
10             {
11                 return string.Empty;
12             }
13             string ret = string.Empty;
14             using (Process p = new Process())
15             {
16                 p.StartInfo.FileName = Program.AdbPath;// @"C:\Android\sdk\platform-tools\adb.exe";
17                 p.StartInfo.Arguments = arguments;
18                 p.StartInfo.UseShellExecute = false;
19                 p.StartInfo.RedirectStandardInput = true;   //重定向标准输入   
20                 p.StartInfo.RedirectStandardOutput = true;  //重定向标准输出   
21                 p.StartInfo.RedirectStandardError = true;   //重定向错误输出   
22                 p.StartInfo.CreateNoWindow = true;
23                 p.Start();
24                 ret = p.StandardOutput.ReadToEnd();
25                 p.Close();
26             }
27             return ret;
28         }
View Code

//图片点击事件

/// <summary>
        /// 黑人底部位置
        /// </summary>
        Point Start;
        /// <summary>
        /// 图案中心或者白点位置
        /// </summary>
        Point End;
        private void pictureBox1_Click(object sender, EventArgs e)
        {
            var me = ((System.Windows.Forms.MouseEventArgs)(e));
            if (me.Button==MouseButtons.Left)//按下左键是黑人底部的坐标
            {
                Start = ((System.Windows.Forms.MouseEventArgs)(e)).Location;
            }
            else if (me.Button == MouseButtons.Right)//按下右键键是黑人底部的坐标
            {
                End = ((System.Windows.Forms.MouseEventArgs)(e)).Location;
                //计算两点直接的距离
                double value = Math.Sqrt(Math.Abs(Start.X - End.X) * Math.Abs(Start.X - End.X) + Math.Abs(Start.Y - End.Y) * Math.Abs(Start.Y - End.Y));
                Text = string.Format("两点之间的距离:{0},须要按下时间:{1}", value, (3.999022243950134 * value).ToString("0")); 
                //3.999022243950134  这个是我经过屡次模拟后获得 我这个分辨率的最佳时间
                cmdAdb(string.Format("shell input swipe 100 100 200 200 {0}", (3.999022243950134 * value).ToString("0")));
            }
        }
View Code

就这样核心代码就完成了 是否是赶忙很简单了。。

 

最后放出效果把 ,(惋惜被我女票手贱就截屏了,截屏的时候手碰了屏幕 致使按下去跳下去了,否则我是要刷到1W分的 哈哈)

 

 我估计这个分数 纯手玩 估计比较心碎把 哈哈  朋友圈就霸占第一名把  哈哈 

 

 最后给源码把  地址:https://files.cnblogs.com/files/dotnet-org-cn/tiaotitiao.rar

相关文章
相关标签/搜索