1.窗体

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace 微信跳一跳辅助
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
            int titleh = Height - ClientSize.Height;
            int titlew = Width - ClientSize.Width;
            Height = height + titleh;
            Width = width + titlew;

}
        int time = int.Parse(System.Configuration.ConfigurationSettings.AppSettings["Time"]);//点击后截图时间;测试发现不能设太小
        string path = System.Configuration.ConfigurationSettings.AppSettings["AdbPath"];//adb.exe所在路径,徐包含adb.exe
        int height = int.Parse(System.Configuration.ConfigurationSettings.AppSettings["Height"]);//图片高度,一般截取第一张图后,打开图片用截图工具拖一下看看图片高度宽度各是多少
        int width =int.Parse(System.Configuration.ConfigurationSettings.AppSettings["Width"]);//图片宽度
        bool canCLick = false;
        Point Start;
        Point End;
        private void pictureBox1_Click(object sender, EventArgs e)

{
            if (!canCLick)
            {
                Text = Application.ProductName + "(不允许点击!)";
                return;
            }
            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)//目标位置
            {
                if(Start.Equals(new Point(0, 0)))
                {
                    GetPhoneScreen();
                    Text = Application.ProductName + "(为你刷新手机屏幕)";
                    return;
                }
                End = ((System.Windows.Forms.MouseEventArgs)(e)).Location;
                //计算两点直接的距离
                //3.999022243950134这个值来自网络大神,本文思路也是按照网上别人给出的实例思路来的!
                double value = Math.Sqrt(Math.Pow(Math.Abs(Start.X - End.X),2)+Math.Pow( Math.Abs(Start.Y - End.Y),2));
               Text = Application.ProductName+ string.Format("(距离{0}需要时间:{1})", value, (3.999022243950134 * value).ToString("0"));
              new ProcessDef(ProcessDefEnum.other)//此处引用本人自己写的,以前封装的类库,文后会贴ProcessDef源码,也可百度或者直接使用DotNet文章中的写法
                {
                    FileName = path,
                    CommandText= string.Format("shell input swipe 100 100 200 200 {0}", (3.999022243950134 * value).ToString("0"))
               }.RunGetResult();
                canCLick = false;
                Start = new Point(0, 0);
                GetPhoneScreen();
            }
        }
        void GetPhoneScreen()
        {
            try
            {
                if (File.Exists("D:tyt.png"))
            {
                pictureBox1.Image = null;
                Thread.Sleep(time);
                GC.Collect();
                File.Delete("D:tyt.png");
            }
            new ProcessDef(ProcessDefEnum.other)
            {
                FileName = path,
                CommandText = "shell /system/bin/screencap -p /sdcard/tyt.png"
            }.RunGetResult();
            Thread.Sleep(5);
            new ProcessDef(ProcessDefEnum.other)
            {
                FileName = path,
                CommandText = "pull /sdcard/tyt.png D:tyt.png"
            }.RunGetResult();
            pictureBox1.Image = new Bitmap("D:tyt.png");
            canCLick = true;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
        private void Form1_Load(object sender, EventArgs e)
        {
            GetPhoneScreen();
        }       
    }

}

2.

public class ProcessDef

{
            public ProcessDef(ProcessDefEnum defEnum)
        {
            StartType = defEnum;
            switch (StartType)
            {
                case ProcessDefEnum.cmd:

filename = "cmd.exe";
                    break;
                case ProcessDefEnum.PwoerShell:

filename = "PowerShell.exe";
                    break;
                default: break;
            }
            }
            public delegate void ResultHandler(string msg);
            public event ResultHandler OnResult;
            string filename = string.Empty;
            public string FileName
            {
                get { return filename; }
                set
                {
                    switch (StartType)
                    {
                        case ProcessDefEnum.cmd:

filename = "cmd.exe";
                            break;
                        case ProcessDefEnum.PwoerShell:

filename = "PowerShell.exe";
                            break;
                        case ProcessDefEnum.other:
                            if (!string.IsNullOrEmpty(value))
                            {
                            filename = value;
                            }
                            break;
                    }
                }
            }
            public string WorkDir { get; set; }
            public string CommandText { get; set; } = "echo .....";
            public bool UseShell { set { UseShell = value; } }
            public bool ShowConsole { get; set; } = false;
            public bool RedirectError { get; set; } = true;
            public bool RedirectInput { get; set; } = true;
            public bool RedirectdOutput { get; set; } = true;
            ProcessDefEnum StartType;
            string RuncmdOrPowerShell( bool rtn=false)
            {
                ProcessStartInfo psi = new ProcessStartInfo()
                {
                    FileName = FileName,
                    RedirectStandardError = RedirectError,
                    RedirectStandardInput = RedirectInput,
                    RedirectStandardOutput = RedirectdOutput,
                    CreateNoWindow = !ShowConsole,
                    UseShellExecute = false,
                };
                if (!string.IsNullOrEmpty(WorkDir) && Directory.Exists(WorkDir))
                {
                    psi.WorkingDirectory = WorkDir;

}
                Process process = new Process()
                {
                    StartInfo = psi
                };
                process.Start();
                process.StandardInput.WriteLine(CommandText);
                process.StandardInput.WriteLine ("exit");
                process.StandardInput.AutoFlush = true;
            if (rtn)
            {
                return process.StandardOutput.ReadToEnd();
            }
            else
            {
                while (!process.StandardOutput.EndOfStream)
                {
                    string msg = process.StandardOutput.ReadLine();
                    if (!string.IsNullOrEmpty(msg))
                        OnResult?.Invoke(msg);
                }
                return "";
            }
               // process.WaitForExit();
            }
            string RunOther(bool rtn = false)
        {
            ProcessStartInfo psi = new ProcessStartInfo()
            {
                FileName = FileName,
                RedirectStandardError = RedirectError,
                RedirectStandardInput = RedirectInput,
                RedirectStandardOutput = RedirectdOutput,
                CreateNoWindow = !ShowConsole,
                UseShellExecute = false,
                Arguments = CommandText,
            };

if (!string.IsNullOrEmpty(WorkDir) && Directory.Exists(WorkDir))
            {
                psi.WorkingDirectory = WorkDir;

}
            Process process = new Process()
            {
                StartInfo = psi
            };
            process.Start();
            if (rtn)
            {
                return process.StandardOutput.ReadToEnd();
            }
            else
            {
                OnResult?.Invoke(filename + " " + CommandText);
                while (!process.StandardOutput.EndOfStream)
                {
                    string msg = process.StandardOutput.ReadLine();
                    if (!string.IsNullOrEmpty(msg))
                        OnResult?.Invoke(msg);
                }
                return "";
            }
        }
            public void Run()
            {
            switch (StartType)
            {
                case ProcessDefEnum.cmd:
                case ProcessDefEnum.PwoerShell:
                    RuncmdOrPowerShell();
                    break;
                case ProcessDefEnum.other:
                    RunOther();
                    break;
                default:break;
            }
            }
            public string RunGetResult()
        {
            string result = string.Empty;
            switch (StartType)
            {
                case ProcessDefEnum.cmd:
                case ProcessDefEnum.PwoerShell:
                  result=  RuncmdOrPowerShell();
                    break;
                case ProcessDefEnum.other:
                   result= RunOther();
                    break;
                default:break;
            }
            return result;
        }
       
    }
    public enum ProcessDefEnum
    {
        cmd = 1,
        PwoerShell = 2,
        other = 3
    }

3.Program

namespace 微信跳一跳辅助
{
    static class Program
    {
        /// <summary>
        /// 应用程序的主入口点。
        /// </summary>
        [STAThread]
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new Form1());
        }
    }
}

4.App.config

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
    <startup> 
        <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
    </startup>
  <appSettings>
    <add key="AdbPath" value="D:\tools\Adb\adb.exe"/>
    <add key="Time" value="700"/>
    <add key="Height" value="620"/>
    <add key ="Width" value="375"/>
  </appSettings>
</configuration>

本文调用adb的程序不建议用文中贴出的类,本人用是因为有封装的Dll直接调用RunGetResult()即可:

给大家搜一个:

建议使用(以下形式)以下代码来自于http://blog.csdn.net/feifei_csdn/article/details/53455490:

  1. System.Diagnostics.Process p = new System.Diagnostics.Process();
  2. p.StartInfo.UseShellExecute = false;
  3. p.StartInfo.CreateNoWindow = true;
  4. p.StartInfo.FileName = "cmd.exe";
  5. p.StartInfo.Arguments = "/c adb shell cat /proc/gesture_state";
  6. p.StartInfo.RedirectStandardError = true;
  7. p.StartInfo.RedirectStandardInput = true;
  8. p.StartInfo.RedirectStandardOutput = true;
  9. p.Start();
  10. string outtr = p.StandardOutput.ReadToEnd();
  11. MessageBox.Show(outtr);
  12. p.Close();

微信小程序挑一挑辅助的更多相关文章

  1. 微信小程序 ui框架(辅助)

    WeUi: https://weui.io/ https://github.com/weui/weui-wxss/ Wa-Ui: https://github.com/liujians/Wa-UI/w ...

  2. 用python一步一步教你玩微信小程序【跳一跳】

    12月28日,微信上线了小游戏「跳一跳」,瞬间成了全民游戏,如何牢牢占据排行榜的第一位呢?用Python帮助你,Python真的无所不能. 作为技术出身的我们,是不是想用技术改变排名呢? 注意:本文适 ...

  3. 微信小程序开发03-这是一个组件

    编写组件 基本结构 接上文:微信小程序开发02-小程序基本介绍 我们今天先来实现这个弹出层: 之前这个组件是一个容器类组件,弹出层可设置载入的html结构,然后再设置各种事件即可,这种组件有一个特点: ...

  4. 微信小程序写tab切换

    微信小程序之tab切换效果,如图: 最近在学习微信小程序并把之前的公司app搬到小程序上,挑一些实现效果记录一下(主要是官方文档里没说的,毕竟官方文档只是介绍功能) .wxml代码: <view ...

  5. 商业版微信小程序开发流程

    一.产品阶段 ①功能规划思维导图——产品经理了解清楚整个项目需求,产出清晰明确的功能需求说明. ②需求报价预算——产品经理确定好功能需求后,输出整个项目开发的报价方案. ③组建技术开发团队——初步确认 ...

  6. Spring+微信小程序 卡券打通

    近期公司项目需要使用到微信卡券模块,主要做的是在小程序打通微信卡券,实现小程序领取卡券的功能效果. 简单说下涉及的东西: Springboot—使用springboot做后端接口,非常便捷 并且根本是 ...

  7. 微信小程序模板消息群发解决思路

    基于微信的通知渠道,微信为开发者提供了可以高效触达用户的模板消息能力,以便实现服务的闭环并提供更佳的体验.(微信6.5.2及以上版本支持模板功能.低于该版本将无法收到模板消息.) 模板推送位置:服务通 ...

  8. 「小程序JAVA实战」微信小程序简介(一)

    转自:https://idig8.com/2018/08/09/xiaochengxu-chuji-01/ 一直想学习小程序,苦于比较忙,加班比较多没时间,其实这都是理由,很多时候习惯了搬砖,习惯了固 ...

  9. 小程序语音红包开发中 汉字转拼音的问题 微信小程序红包开发遇到的坑

    公司最近在开发微信小程序的红包功能,语音红包需要用到文字转拼音的功能. 之前介绍过怎么将中文的汉字转为拼音的,具体看下面这篇文章. 微信语音红包小程序开发如何提高精准度 红包小程序语音识别精准度 微信 ...

  10. BeautyWe.js 一套专注于微信小程序的开发范式

    摘要: 小程序框架... 作者:JerryC 原文:BeautyWe.js 一套专注于微信小程序的开发范式 Fundebug经授权转载,版权归原作者所有. 官网:beautywejs.com Repo ...

随机推荐

  1. convirt介绍

    convirt2.0是一款使用python和jquery结合编写的其于web的集中管理xen服务的程序.该程序在xen 社区项目,管理项目中被使用的量很高,convirt开发有开源版本与企业版本,企业 ...

  2. 从co到koa01-co

    thunk 他的发展是由函数的求值策略的分歧决定的,两种求值策略 传值调用,在进入函数体之前就直接执行完,把值传进去 传名调用,将表达式传入函数体,只在用到他的时候求值 传名函数的编译器实现,其实就是 ...

  3. 【spring cloud】spring cloud中启动eureka集群时候,发生端口已经绑定的报错The Tomcat connector configured to listen on port 8000 failed to start. The port may already be in use or the connector may be misconfigured.

    在分别设置 进行微服务eureka集群启动时候,执行命令行启动jar包时候,报错前面一个端口8000已经被使用,而我这里启动的配置文件中端口号是8001,怎么会导致端口冲突呢?? 但是报错我的端口冲突 ...

  4. [Android Memory] Android系统中查看某个应用当前流量的方法

    转载自: http://blog.sina.com.cn/s/blog_628cc2b70101dbyy.html 一.查看原理:某个应用的网络流量数据保存在系统的/proc/uid_stat/$UI ...

  5. 深入C(关键字)

    C语言标准定义的32个关键字 关键字 意 义 auto 声明自动变量,缺省时编译器一般默认为auto int 声明整型变量 double 声明双精度变量 long 声明长整型变量 char 声明字符型 ...

  6. ylbtech-LanguageSamples-Indexers(索引器)

    ylbtech-Microsoft-CSharpSamples:ylbtech-LanguageSamples-Indexers(索引器) 1.A,示例(Sample) 返回顶部 “索引器”示例 本示 ...

  7. Android Killer

    首先,我们先看一Android界有名的大神写关于Android反编译的博客: 郭 大 侠:http://blog.csdn.net/guolin_blog/article/details/497380 ...

  8. pyPdf - 用Python方便的处理PDF文档

    pyPdf库 ( http://pybrary.net/pyPdf/ ) ,操作起来相当直接易懂,把代码贴在这儿,做个记录.  1 from pyPdf import PdfFileWriter, P ...

  9. Java笔记8:Hibernate连接Oracle

    1下载hibernate-3.6.0 Final.zip到任意目录,解压缩后得到hibernate目录 2下载slf4j-1.7.13.zip到任意目录,解压缩后得到slf4j-1.7.13 3操作数 ...

  10. 从外部重置一个运行中consumer group的消费进度

    对于0.10.1以上版本的kafka, 如何从外部重置一个运行中的consumer group的进度呢?比如有一个控制台,可以主动重置任意消费组的消费进度重置到12小时之前, 而用户的程序可以保持运行 ...