using System; using System.Drawing.Imaging; using System.Windows.Forms; using…
- User
using System; using System.Drawing.Imaging; using System.Windows.Forms; using System.Threading; using BlumClicker;
public static class Screenshot { [STAThread] public static void Start() { int screenWidth = Screen.PrimaryScreen.Bounds.Width; int screenHeight = Screen.PrimaryScreen.Bounds.Height;
using (Bitmap bitmap = new Bitmap(screenWidth, screenHeight, PixelFormat.Format32bppArgb)) { using (Graphics g = Graphics.FromImage(bitmap)) g.CopyFromScreen(0, 0, 0, 0, bitmap.Size, CopyPixelOperation.SourceCopy); Rectangle rect = new Rectangle(0, 0, bitmap.Width, bitmap.Height); BitmapData bmpData = bitmap.LockBits(rect, ImageLockMode.ReadOnly, bitmap.PixelFormat); IntPtr ptr = bmpData.Scan0; int bytes = Math.Abs(bmpData.Stride) * bitmap.Height; byte[] rgbValues = new byte[bytes]; ushort[,] cords = new ushort[bytes, 2]; System.Runtime.InteropServices.Marshal.Copy(ptr, rgbValues, 0, bytes); bitmap.UnlockBits(bmpData); int cordsIdx = 0; for (int y = 0; y < bitmap.Height; y++) { for (int x = 0; x < bitmap.Width; x++) { if (Program.paused) return; int index = y * bmpData.Stride + x * 4; byte blue = rgbValues[index]; byte green = rgbValues[index + 1]; byte red = rgbValues[index + 2]; int treshold = 15; if (Math.Abs(red - 183) < treshold && Math.Abs(green - 229) < treshold && Math.Abs(blue - 19) < treshold) { cords[cordsIdx, 0] = (ushort)x; cords[cordsIdx, 1] = (ushort)y; cordsIdx++; } } } if (cordsIdx > 0) { ushort[,] cordsTrim = new ushort[cordsIdx, 2]; for (int i = 0; i < cordsIdx; i++) { cordsTrim[i, 0] = cords[i, 0]; cordsTrim[i, 1] = cords[i, 1]; } Random random = new Random(); int idx = random.Next(0, cordsTrim.Length-1); Mouse.Click(cordsTrim[idx, 0], cordsTrim[idx, 1]); } } }} Почему происходит index out of range?
- Assistant