private void btnCaptureContour_Click(object sender, EventArgs e) { var proc = Process.GetProcessesByName(txtProcessName.Text)[0]; User32.SetForegroundWindow(proc.MainWindowHandle); var top = int.Parse(txtYCaptureContour.Text); var left = int.Parse(txtXCaptureContour.Text); var height = int.Parse(txtHCaptureContour.Text); var width = int.Parse(txtWCaptureContour.Text); var rect = new User32.Rect {top = top, left = left, bottom = top + height, right = left + width}; User32.GetWindowRect(proc.MainWindowHandle, ref rect); var bmp = new Bitmap(width, height, PixelFormat.Format32bppArgb); Graphics graphics = Graphics.FromImage(bmp); graphics.CopyFromScreen(left, top, 0, 0, new Size(width, height), CopyPixelOperation.SourceCopy); //try //{ // var q = FindRectangle(imgSrc, imgDst); //} //catch (Exception ex) //{ //} //pictCaptureContour.Image = imgDst.ToBitmap(); }
private void btnCaptureCaptcha_Click(object sender, EventArgs e) { var proc = Process.GetProcessesByName(txtProcessName.Text)[0]; User32.SetForegroundWindow(proc.MainWindowHandle); var top = int.Parse(txtYCaptcha.Text); var left = int.Parse(txtXCaptcha.Text); var height = int.Parse(txtHCapture.Text); var width = int.Parse(txtWCapture.Text); var rect = new User32.Rect() {top = top, left = left, bottom = top + height, right = left + width}; User32.GetWindowRect(proc.MainWindowHandle, ref rect); var bmp = new Bitmap(width, height, PixelFormat.Format32bppArgb); Graphics graphics = Graphics.FromImage(bmp); graphics.CopyFromScreen(left, top, 0, 0, new Size(width, height), CopyPixelOperation.SourceCopy); pictCapture.Image = bmp; rawCaptcha = new Image<Bgr, byte>(bmp); }