您的位置:时时app平台注册网站 > 编程知识 > 贴一个微信小程序跳一跳辅助时时app平台注册网

贴一个微信小程序跳一跳辅助时时app平台注册网

2019-11-28 03:24

            startInfo.UseShellExecute = false;

 

            IJobDetail detail = JobBuilder.Create<AutoUpdateQuartzJob>()

2.

            startInfo.FileName = @"cmd.exe ";

//此程序遵照Wechat民众号DotNet的篇章》net开垦一个Wechat跳大器晚成跳协理而来,

            p.StartInfo = startInfo;

        {
            if (!canCLick)
            {
                Text = Application.ProductName "(不允许点击!)";
                return;
            }
            var me = ((System.Windows.Forms.MouseEventArgs)(e));

            sche.Start();

            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();
        }      
    }

            p.Start();

4.App.config

> installutil XXX.exe

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

2卡塔 尔(阿拉伯语:قطر‎ Quartz 定期进行步骤1卡塔尔国      

 

  cmd 管理员身份运转

其基本时间周密值直接援用自小说;

                .Build();

        }
        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)

                .WithSimpleSchedule(x => x.WithIntervalInSeconds(15).RepeatForever())

3.Program

            p.Close();

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;

                .StartNow()

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

>  cd  C:WindowsMicrosoft.NETFrameworkv4.0.30319

  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.                 
  10.             p.Start();  
  11.   
  12.             string outtr = p.StandardOutput.ReadToEnd();  
  13.             MessageBox.Show(outtr);  
  14.             p.Close();   

 

            }
            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
    }

  1. 涉嫌本领:

    Winservice: 用system身份后台跑;  Quartz:按时任务;  SVN 

  2. 思路:

    Quartz定期调用cmd 程序,实践SVN update 命令,整个程序寄宿在Winservice

  3. 步骤:

    1卡塔 尔(英语:State of Qatar)service 用local system账户设置,通过Process 运维cmd 程序。

    推行核心代码: 

        string path = ConfigurationManager.AppSettings["localPath"].ToString();    

        string username = ConfigurationManager.AppSettings["username"].ToString();

        string password = ConfigurationManager.AppSettings["password"].ToString(); 

                    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:

            //startInfo.Arguments = " /c svn update " path " --username mashenghao --password mashenghao ";

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

 

                }
                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,
            };

            IJobListener listener = new AutoUpdateQuartzJobListern();

1.窗体

3) 安装winservice

正文调用adb的次序不建议用文中贴出的类,本人用是因为有包装的Dll直接调用RunGetResult()就能够:

      ISchedulerFactory fact = new StdSchedulerFactory();

namespace Wechat跳风流倜傥跳支持
{
    static class Program
    {
        /// <summary>
        /// 应用程序的主入口点。
        /// </summary>
        [STAThread]
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new Form1());
        }
    }
}

            sche.ScheduleJob(detail, trigger);

                        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;

 

<?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:toolsAdbadb.exe"/>
    <add key="Time" value="700"/>
    <add key="Height" value="620"/>
    <add key ="Width" value="375"/>
  </appSettings>
</configuration>

            startInfo.RedirectStandardInput = true;

        public class ProcessDef

            startInfo.RedirectStandardOutput = true;

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

                .WithIdentity("SVNAutoUpdate", "SVNAutoUpdate")

提出采纳(以下情势卡塔尔国以下代码来自于

            p.StandardInput.AutoFlush = true;

namespace Wechat跳意气风发跳援救
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
            int titleh = Height - ClientSize.Height;
            int titlew = Width - ClientSize.Width;
            Height = height titleh;
            Width = width titlew;

                .Build();

}

            ITrigger trigger = TriggerBuilder.Create()

给大家搜二个:

            p.StandardInput.WriteLine("svn update " path " --username " username " --password " password " &exit ");

            IScheduler sche = fact.GetScheduler();

                .WithIdentity("SVNAutoUpdateTrigger", "SVNAutoUpdateTrigger")

    Process p = new Process();

            ProcessStartInfo startInfo = new System.Diagnostics.ProcessStartInfo();

            string output = p.StandardOutput.ReadToEnd();

            p.WaitForExit();

本文由时时app平台注册网站发布于编程知识,转载请注明出处:贴一个微信小程序跳一跳辅助时时app平台注册网

关键词: