Unhandled exception at 0x7586A8B2 (KernelBase.dll) in TargetPriceAlert.exe: 0xE0434352 (parameters: 0x80131604, 0x00000000, 0x00000000, 0x00000000, 0x72EC0000). using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Drawing.Imaging; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; using System.Threading; using Tesseract; using System.Media; using ImageFormat = System.Drawing.Imaging.ImageFormat; namespace TargetPriceAlert { public partial class SetPrice : Form { String readingtext; Double readingnumber, up, down; Thread y; int yes = 0; bool go = true; int setalertcount = 0; int screenx, screeny, screenw, screenh; Size screens; DialogResult result; public SetPrice(Int32 x, Int32 y, Int32 w, Int32 h, Size s) { screenx = x; screeny = y; screenw = w; screenh = h; screens = s; InitializeComponent(); //C#: how to take a screenshot of a portion of screen https://stackoverflow.com/a/3306633/5260872 Rectangle rect = new Rectangle(x, y, w, h); Bitmap bmp = new Bitmap(rect.Width, rect.Height, PixelFormat.Format32bppArgb); Graphics g = Graphics.FromImage(bmp); g.CopyFromScreen(rect.Left, rect.Top, 0, 0, s, CopyPixelOperation.SourceCopy); pbCapture.Image = bmp; } private void btnSetAlert_Click(object sender, EventArgs e) { if (setalertcount >= 1) { } else { go = true; yes = 0; y = new Thread(ScreenCapture); y.IsBackground = true; y.Start(); setalertcount++; } } private void btnSetPrice_Click(object sender, EventArgs e) { var u = double.TryParse(textBoxUp.Text, out up); var d = double.TryParse(textBoxDown.Text, out down); if (u) { textBoxuppriceR.Text = textBoxUp.Text; } if (d) { textBoxdownpriceR.Text = textBoxDown.Text; } } private void btnHome_Click(object sender, EventArgs e) { Form1 home = new Form1(); this.Hide(); home.Show(); } private void SetPrice_FormClosing(object sender, FormClosingEventArgs e) { go = false; } private void btnStop_Click(object sender, EventArgs e) { go = false; setalertcount = 0; } private void ScreenCapture() { while (go) { Rectangle rect = new Rectangle(screenx, screeny, screenw, screenh); Bitmap capture = new Bitmap(rect.Width, rect.Height, PixelFormat.Format32bppArgb); Graphics g = Graphics.FromImage(capture); g.CopyFromScreen(rect.Left, rect.Top, 0, 0, screens, CopyPixelOperation.SourceCopy); try { pbCapture.Invoke(new MethodInvoker( delegate () { pbCapture.Image = capture; } )); } catch { } ReadingPrice(); try { textBoxReadingPrice.Invoke(new MethodInvoker( delegate () { textBoxReadingPrice.Text = readingtext; })); } catch { } bool ss = double.TryParse(readingtext, out readingnumber); if (ss) ComparePrice(); capture.Dispose(); if (yes == 1) { SoundPlayer player = new SoundPlayer("C:\\Windows\\Media\\Ring03.wav"); player.Play(); //or player.PlayLooping(); //then whenver you want to stop string message = "The Price is" + readingtext; string title = "The Target Price is Hitting"; this.Invoke(new MethodInvoker(delegate () { result = MessageBox.Show(message, title); })); if (result == DialogResult.OK) { go = false; player.Stop(); setalertcount = 0; break; } } Thread.Sleep(100); } } private void ReadingPrice() { Rectangle rect = new Rectangle(screenx, screeny, screenw, screenh); Bitmap readingpicture = new Bitmap(rect.Width, rect.Height, PixelFormat.Format32bppArgb); Graphics g = Graphics.FromImage(readingpicture); g.CopyFromScreen(rect.Left, rect.Top, 0, 0, screens, CopyPixelOperation.SourceCopy); var img = new Bitmap(readingpicture); var ocr = new TesseractEngine("./tessdata", "eng", EngineMode.TesseractAndLstm); var text = ocr.Process(img); readingtext = text.GetText(); readingpicture.Dispose(); } private void ComparePrice() { if (readingnumber >= up || readingnumber <= down) { yes = 1; } } } } -- You received this message because you are subscribed to the Google Groups "tesseract-ocr" group. To unsubscribe from this group and stop receiving emails from it, send an email to tesseract-ocr+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/tesseract-ocr/b6293d02-3a7c-4fab-839b-70fdce79e32en%40googlegroups.com.