private void Form1_Load(object sender, EventArgs e) { var rawDeviceEnumerator = new RawInputDeviceEnumerator(); foreach (var rawInputDevice in rawDeviceEnumerator.Devices.Where( d => d.DeviceType == Win32.RawInputDeviceType.Mouse)) { Console.WriteLine( "{0}:\n\tName = {1}\n\tHandle: = {2}\n", rawInputDevice.DeviceType, rawInputDevice.DeviceName, rawInputDevice.DeviceHandle); } if (File.Exists("offsetX")) { offset.X = int.Parse(File.ReadAllText("offsetX")); offset.Y = int.Parse(File.ReadAllText("offsetY")); } fov = new Fov { Resolution = new Point(1920, 1080), FieldOfView = new Rectangle((1920 / 2) - boxSize.X / 2, (1080 / 2) - boxSize.Y / 2, boxSize.X, boxSize.Y) }; bot = new Aimbot(new Point(boxSize.X / 2, boxSize.Y / 2)); scanner = new Scanner(); Thread thread = new Thread(CaptureThread); thread.IsBackground = true; thread.Start(); }
public static Bitmap CaptureFov(Fov fov) { var screenCopy = new Bitmap(fov.FieldOfView.Width, fov.FieldOfView.Height, PixelFormat.Format24bppRgb); using (var gdest = Graphics.FromImage(screenCopy)) using (var gsrc = Graphics.FromHwnd(IntPtr.Zero)) { var hSrcDc = gsrc.GetHdc(); var hDc = gdest.GetHdc(); var retval = BitBlt(hDc, 0, 0, fov.FieldOfView.Width, fov.FieldOfView.Height, hSrcDc, fov.FieldOfView.X, fov.FieldOfView.Y, (int)CopyPixelOperation.SourceCopy); gdest.ReleaseHdc(); gsrc.ReleaseHdc(); } return(screenCopy); }