Advertisement
Guest User

egeeqaga

a guest
Mar 29th, 2020
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.49 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Runtime.InteropServices;
  5. using System.Text;
  6. using System.Threading.Tasks;
  7. using AutoItX3Lib;
  8.  
  9. namespace Automate
  10. {
  11.     class Autoit
  12.     {
  13.         [DllImport("ImageSearchDLL32.dll")]
  14.         public static extern IntPtr ImageSearch(int x, int y, int right, int bottom, [MarshalAs(UnmanagedType.LPStr)]string imagePath);
  15.         public static string[] UseImageSearch(string imgPath, string tolerance)
  16.         {
  17.             imgPath = "*" + tolerance + " " + imgPath;
  18.  
  19.             IntPtr result = ImageSearch(0, 0, 1920, 1080, imgPath);
  20.             string res = Marshal.PtrToStringAnsi(result);
  21.  
  22.             if (res[0] == '0') return null;
  23.  
  24.             string[] data = res.Split('|');
  25.  
  26.             int x; int y;
  27.             int.TryParse(data[1], out x);
  28.             int.TryParse(data[2], out y);
  29.  
  30.             return data;
  31.         }
  32.         AutoItX3 auto = new AutoItX3();
  33.  
  34.         public void mClick(string ClickSide, int x, int y, int manyClick, int Speed)
  35.         {
  36.             auto.MouseClick(ClickSide, x, y, manyClick, Speed);
  37.         }
  38.         public void mSleep(int millisecondi)
  39.         {
  40.             auto.Sleep(millisecondi);
  41.         }
  42.  
  43.         public struct Point
  44.         {
  45.             public int x;
  46.             public int y;
  47.             public Point(int x_, int y_)
  48.             {
  49.                 x = x_;
  50.                 y = y_;
  51.             }
  52.         }
  53.         static Point[] points = new Point[] {
  54.         new Point(1266, 562),
  55.         new Point(1298, 771)
  56.         };
  57.         internal void mClick(string v1, Form1.Point point1, Form1.Point point2, int v2, int v3)
  58.         {
  59.             throw new NotImplementedException();
  60.         }
  61.         public void myResult(int Counter, int numFailure)
  62.         {
  63.  
  64.             Autoit Cautoit = new Autoit();
  65.             string image = (@"C:\winningNumber.png");
  66.             string[] results = UseImageSearch(image, "30");
  67.             if (results == null)
  68.             {
  69.                 numFailure = numFailure + 1;
  70.                 Counter = numFailure * 2;
  71.                 Cautoit.mClick("LEFT", points[1].x, points[1].y, Counter, 2);
  72.             }
  73.             else
  74.             {
  75.                 Cautoit.mClick("LEFT", points[1].x, points[1].y, 1, 2);
  76.                 return;
  77.             }
  78.         }
  79.  
  80.         internal void myResult(int counter, object numFailure)
  81.         {
  82.             throw new NotImplementedException();
  83.         }
  84.     }
  85. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement