예제 #1
0
 private void btnOpenTesseractOcrDemo_Click(object sender, EventArgs e)
 {
     try
     {
         this.WindowState = FormWindowState.Minimized;
         OCRImage ocrI = new OCRImage();
         ocrI.ShowDialog();
         this.WindowState = FormWindowState.Normal;
         //Environment.Exit(0);
     }
     catch (Exception)
     {
     }
 }
예제 #2
0
        private void SynData(object config)
        {
            try
            {
                GetHwndConfig hwndConfig = (GetHwndConfig)config;
                int           currenHwnd = GetTopHwnd(hwndConfig);
                while (true)
                {
                    if (IsSrceenImage)
                    {
                        Bitmap bmp = GetHwndInfor.GetHwndImage(currenHwnd);
                        Invoke(new Action(() =>
                        {
                            this.pictureBox1.Image = bmp;

                            bmp             = OCRImage.ImageProcessing(bmp);//图像处理
                            string strTitle = OCRImage.OCRBitmpa(bmp).OCRContent;
                            Invoke(new Action(() =>
                            {
                                this.labOCRConten.Text = strTitle;
                                addLoog("OCR识别到的内容为:" + strTitle);
                            }));
                        }));
                    }
                    else
                    {
                        string strTitle = GetHwndInfor.GetHwndTitle(currenHwnd);
                        if (strTitle == "")
                        {
                            addLoog("开始重新定位");
                            currenHwnd = GetTopHwnd(hwndConfig);
                        }

                        Invoke(new Action(() =>
                        {
                            this.labHwendTitle.Text = strTitle;
                            addLoog("获取到句柄内容为:" + strTitle);
                        }));
                    }
                    Thread.Sleep(1000);
                }
            }
            catch (Exception ex)
            {
                addLoog("异常:" + ex.Message);
            }
        }