Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Runtime.InteropServices;
- using System.Text;
- using System.Threading.Tasks;
- using AutoItX3Lib;
- namespace Automate
- {
- class Autoit
- {
- [DllImport("ImageSearchDLL32.dll")]
- public static extern IntPtr ImageSearch(int x, int y, int right, int bottom, [MarshalAs(UnmanagedType.LPStr)]string imagePath);
- public static string[] UseImageSearch(string imgPath, string tolerance)
- {
- imgPath = "*" + tolerance + " " + imgPath;
- IntPtr result = ImageSearch(0, 0, 1920, 1080, imgPath);
- string res = Marshal.PtrToStringAnsi(result);
- if (res[0] == '0') return null;
- string[] data = res.Split('|');
- int x; int y;
- int.TryParse(data[1], out x);
- int.TryParse(data[2], out y);
- return data;
- }
- AutoItX3 auto = new AutoItX3();
- public void mClick(string ClickSide, int x, int y, int manyClick, int Speed)
- {
- auto.MouseClick(ClickSide, x, y, manyClick, Speed);
- }
- public void mSleep(int millisecondi)
- {
- auto.Sleep(millisecondi);
- }
- public struct Point
- {
- public int x;
- public int y;
- public Point(int x_, int y_)
- {
- x = x_;
- y = y_;
- }
- }
- static Point[] points = new Point[] {
- new Point(1266, 562),
- new Point(1298, 771)
- };
- internal void mClick(string v1, Form1.Point point1, Form1.Point point2, int v2, int v3)
- {
- throw new NotImplementedException();
- }
- public void myResult(int Counter, int numFailure)
- {
- Autoit Cautoit = new Autoit();
- string image = (@"C:\winningNumber.png");
- string[] results = UseImageSearch(image, "30");
- if (results == null)
- {
- numFailure = numFailure + 1;
- Counter = numFailure * 2;
- Cautoit.mClick("LEFT", points[1].x, points[1].y, Counter, 2);
- }
- else
- {
- Cautoit.mClick("LEFT", points[1].x, points[1].y, 1, 2);
- return;
- }
- }
- internal void myResult(int counter, object numFailure)
- {
- throw new NotImplementedException();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement