// 截图取字(OCR 文字识别) // 引擎:Windows 10+ 系统自带 OCR(Windows.Media.Ocr),离线、免费、不传图。 // 说明:net48 直接引用 WinRT winmd 时会撞「union Windows.winmd」依赖问题 //(System.Runtime.WindowsRuntime.dll 是按 union 元数据编译的),所以这里 // 不用 GetAwaiter/AsBuffer 等扩展,改为轮询 IAsyncInfo.Status 等待异步完成, // PNG 经 InMemoryRandomAccessStream + BitmapDecoder 进引擎。全部自包含。 using System; using System.Collections.Generic; using System.Drawing; using System.Drawing.Imaging; using System.IO; using System.Linq; using System.Runtime.InteropServices; using System.Text; using System.Threading; using System.Threading.Tasks; using System.Windows.Forms; using Windows.Foundation; using Windows.Globalization; using Windows.Graphics.Imaging; using Windows.Media.Ocr; using Windows.Storage.Streams; namespace GtOcr { /* ───────────── 核心:OCR 操作 ───────────── */ public static class OcrOps { /* 轮询等待 WinRT 异步操作(替代 await 扩展) */ public static T WaitOp(IAsyncOperation op) { while (op.Status == AsyncStatus.Started) Thread.Sleep(15); if (op.Status == AsyncStatus.Error) throw op.ErrorCode; if (op.Status != AsyncStatus.Completed) throw new InvalidOperationException("异步操作被取消"); return op.GetResults(); } /* 系统里可用的识别语言(装了哪些语言包决定) */ public static List> AvailableLangs() { List> list = new List>(); foreach (Language l in OcrEngine.AvailableRecognizerLanguages) list.Add(new KeyValuePair(l.LanguageTag, l.DisplayName)); return list; } public static OcrEngine CreateEngine(string langTag) { OcrEngine eng = null; if (!string.IsNullOrEmpty(langTag)) eng = OcrEngine.TryCreateFromLanguage(new Language(langTag)); if (eng == null && langTag == null) eng = OcrEngine.TryCreateFromUserProfileLanguages(); if (eng == null) { // 目标语言不可用时退回系统用户语言 eng = OcrEngine.TryCreateFromUserProfileLanguages(); } return eng; } /* PNG 字节 → 识别行。统一丢到线程池,避免 STA 线程被轮询卡住。 */ public static List PngToLines(byte[] png, string langTag) { if (png == null || png.Length == 0) throw new ArgumentException("没有图像数据"); return Task.Run(() => PngToLinesCore(png, langTag)).GetAwaiter().GetResult(); } static List PngToLinesCore(byte[] png, string langTag) { OcrEngine eng = CreateEngine(langTag); if (eng == null) throw new InvalidOperationException( "系统没有可用的 OCR 语言包:请在「设置 → 时间和语言 → 语言」里添加中文或英文语言"); InMemoryRandomAccessStream stream = new InMemoryRandomAccessStream(); DataWriter writer = new DataWriter(stream); writer.WriteBytes(png); WaitOp(writer.StoreAsync()); WaitOp(writer.FlushAsync()); writer.DetachStream(); BitmapDecoder decoder = WaitOp(BitmapDecoder.CreateAsync(stream)); SoftwareBitmap sb = WaitOp(decoder.GetSoftwareBitmapAsync()); OcrResult res = WaitOp(eng.RecognizeAsync(sb)); List lines = new List(); foreach (OcrLine line in res.Lines) lines.Add(line.Text); return lines; } public static string PngToText(byte[] png, string langTag) { return string.Join(Environment.NewLine, PngToLines(png, langTag).ToArray()); } public static string ImageFileToText(string path, string langTag) { return PngToText(ToPngBytes(new Bitmap(path)), langTag); } /* 任意 GDI+ 图像转 PNG 字节(BitmapDecoder 只认流式图像格式) */ public static byte[] ToPngBytes(Image img) { using (MemoryStream ms = new MemoryStream()) { img.Save(ms, ImageFormat.Png); return ms.ToArray(); } } /* 全屏截取(多显示器:虚拟屏幕) */ public static Bitmap CaptureScreen() { Rectangle vs = SystemInformation.VirtualScreen; Bitmap bmp = new Bitmap(vs.Width, vs.Height, PixelFormat.Format32bppArgb); using (Graphics g = Graphics.FromImage(bmp)) { g.CopyFromScreen(vs.X, vs.Y, 0, 0, new Size(vs.Width, vs.Height)); } return bmp; } public static Bitmap Crop(Image src, Rectangle r) { Bitmap outBmp = new Bitmap(Math.Max(1, r.Width), Math.Max(1, r.Height), PixelFormat.Format32bppArgb); using (Graphics g = Graphics.FromImage(outBmp)) { g.DrawImage(src, new Rectangle(0, 0, outBmp.Width, outBmp.Height), r, GraphicsUnit.Pixel); } return outBmp; } /* 选区是否够大(避免误触) */ public static bool IsMeaningful(Rectangle r) { return r.Width >= 8 && r.Height >= 8; } /* 识别结果常带字间空格(中文字逐字识别),给测试和连续文本用 */ public static string StripSpace(string s) { if (s == null) return ""; StringBuilder sb = new StringBuilder(s.Length); foreach (char c in s) { if (!char.IsWhiteSpace(c)) sb.Append(c); } return sb.ToString(); } /* 小图放大 2 倍再识别:小字号/低分屏文字识别率明显更好 */ public static Bitmap MaybeScaleUp(Bitmap src) { if (src.Width >= 800 || src.Height >= 600) return src; int nw = Math.Min(1600, src.Width * 2); int nh = Math.Min(1200, src.Height * 2); Bitmap up = new Bitmap(nw, nh, PixelFormat.Format32bppArgb); using (Graphics g = Graphics.FromImage(up)) { g.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic; g.DrawImage(src, 0, 0, nw, nh); } return up; } } /* ───────────── 全屏选区遮罩 ───────────── */ public class OcrOverlay : Form { Bitmap _bg; // 整屏截图 Rectangle _sel; // 当前选区(虚拟屏幕坐标) bool _dragging; Point _start; public Rectangle Result = Rectangle.Empty; public OcrOverlay() { Rectangle vs = SystemInformation.VirtualScreen; _bg = OcrOps.CaptureScreen(); FormBorderStyle = FormBorderStyle.None; StartPosition = FormStartPosition.Manual; Location = new Point(vs.X, vs.Y); Size = new Size(vs.Width, vs.Height); TopMost = true; ShowInTaskbar = false; KeyPreview = true; Cursor = Cursors.Cross; DoubleBuffered = true; } protected override void OnKeyDown(KeyEventArgs e) { if (e.KeyCode == Keys.Escape) { DialogResult = DialogResult.Cancel; Close(); } base.OnKeyDown(e); } protected override void OnMouseDown(MouseEventArgs e) { if (e.Button == MouseButtons.Right) { DialogResult = DialogResult.Cancel; Close(); return; } _dragging = true; _start = PointToScreen(e.Location); _sel = new Rectangle(_start, Size.Empty); } protected override void OnMouseMove(MouseEventArgs e) { if (!_dragging) return; Point p = PointToScreen(e.Location); _sel = RectFrom(_start, p); Invalidate(); } protected override void OnMouseUp(MouseEventArgs e) { if (!_dragging) return; _dragging = false; if (!OcrOps.IsMeaningful(_sel)) return; Result = _sel; DialogResult = DialogResult.OK; Close(); } static Rectangle RectFrom(Point a, Point b) { return new Rectangle(Math.Min(a.X, b.X), Math.Min(a.Y, b.Y), Math.Abs(a.X - b.X), Math.Abs(a.Y - b.Y)); } protected override void OnPaint(PaintEventArgs e) { Rectangle vs = SystemInformation.VirtualScreen; Graphics g = e.Graphics; // 背景:整屏截图 + 半透明黑罩 g.DrawImage(_bg, 0, 0, vs.Width, vs.Height); using (SolidBrush dark = new SolidBrush(Color.FromArgb(110, 0, 0, 0))) g.FillRectangle(dark, ClientRectangle); if (_sel.Width > 0 && _sel.Height > 0) { Rectangle local = new Rectangle(_sel.X - vs.X, _sel.Y - vs.Y, _sel.Width, _sel.Height); // 选区内恢复原亮度 g.DrawImage(_bg, local, _sel, GraphicsUnit.Pixel); using (Pen pen = new Pen(Color.FromArgb(255, 64, 156, 255), 2)) g.DrawRectangle(pen, local); // 尺寸提示 string tip = _sel.Width + " × " + _sel.Height; using (Font f = new Font("Microsoft YaHei", 9)) using (SolidBrush b = new SolidBrush(Color.FromArgb(230, 30, 34, 40))) { Size ts = TextRenderer.MeasureText(tip, f); int ty = local.Y - ts.Height - 6; if (ty < 2) ty = local.Bottom + 6; g.FillRectangle(b, local.X, ty, ts.Width + 12, ts.Height + 4); TextRenderer.DrawText(g, tip, f, new Point(local.X + 6, ty + 2), Color.White); } } else { using (Font f = new Font("Microsoft YaHei", 11)) TextRenderer.DrawText(g, "拖动框选要识别的文字区域,Esc 取消", f, new Point(24, 20), Color.White); } } protected override void Dispose(bool disposing) { if (disposing && _bg != null) _bg.Dispose(); base.Dispose(disposing); } } /* ───────────── 主窗口 ───────────── */ public partial class OcrForm : Form { const int HOTKEY_SNAP = 1; const uint MOD_ALT = 0x1, MOD_CONTROL = 0x2, MOD_SHIFT = 0x4; [DllImport("user32.dll")] private static extern bool RegisterHotKey(IntPtr h, int id, uint mod, uint vk); [DllImport("user32.dll")] private static extern bool UnregisterHotKey(IntPtr h, int id); ComboBox cmbLang; TextBox txtResult; Label lblStatus; NotifyIcon tray; public OcrForm() { Text = "截图取字 - 绿色工具箱"; Font = new Font("Microsoft YaHei", 9F); StartPosition = FormStartPosition.CenterScreen; Size = new Size(640, 520); MinimumSize = new Size(560, 420); Label top = new Label(); top.Text = "Windows 自带离线 OCR:截图 / 图片 / 剪贴板 → 文字,自动复制到剪贴板"; top.ForeColor = Color.FromArgb(90, 100, 95); top.Location = new Point(16, 14); top.AutoSize = true; Controls.Add(top); Label lblLang = new Label(); lblLang.Text = "识别语言"; lblLang.Location = new Point(16, 46); lblLang.AutoSize = true; Controls.Add(lblLang); cmbLang = new ComboBox(); cmbLang.DropDownStyle = ComboBoxStyle.DropDownList; cmbLang.Location = new Point(76, 42); cmbLang.Width = 220; foreach (var kv in OcrOps.AvailableLangs()) cmbLang.Items.Add(new LangItem(kv.Key, kv.Value)); if (cmbLang.Items.Count == 0) cmbLang.Items.Add(new LangItem(null, "系统未装语言包")); int prefer = 0; for (int i = 0; i < cmbLang.Items.Count; i++) if (((LangItem)cmbLang.Items[i]).Tag == "zh-Hans-CN") { prefer = i; break; } cmbLang.SelectedIndex = prefer; Controls.Add(cmbLang); Button btnSnap = new Button(); btnSnap.Text = "截图取字 (Ctrl+Alt+O)"; btnSnap.Location = new Point(320, 40); btnSnap.Size = new Size(150, 30); btnSnap.Click += (s, e) => SnapAndOcr(); Controls.Add(btnSnap); Button btnFile = new Button(); btnFile.Text = "打开图片…"; btnFile.Location = new Point(478, 40); btnFile.Size = new Size(80, 30); btnFile.Click += OnOpenImage; Controls.Add(btnFile); Button btnClip = new Button(); btnClip.Text = "剪贴板图片"; btnClip.Location = new Point(16, 78); btnClip.Size = new Size(110, 28); btnClip.Click += (s, e) => OnClipboardImage(); Controls.Add(btnClip); Button btnCopy = new Button(); btnCopy.Text = "复制结果"; btnCopy.Location = new Point(134, 78); btnCopy.Size = new Size(90, 28); btnCopy.Click += (s, e) => CopyResult(); Controls.Add(btnCopy); Button btnClear = new Button(); btnClear.Text = "清空"; btnClear.Location = new Point(232, 78); btnClear.Size = new Size(64, 28); btnClear.Click += (s, e) => { txtResult.Text = ""; Log("已清空"); }; Controls.Add(btnClear); txtResult = new TextBox(); txtResult.Multiline = true; txtResult.ScrollBars = ScrollBars.Both; txtResult.WordWrap = false; txtResult.Font = new Font("Consolas", 10.5F); txtResult.Location = new Point(16, 114); txtResult.Size = new Size(542, 290); txtResult.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right; Controls.Add(txtResult); lblStatus = new Label(); lblStatus.Text = "框选屏幕上的任意文字,识别完自动进剪贴板;图片不会上传,全程离线。"; lblStatus.ForeColor = Color.FromArgb(120, 130, 124); lblStatus.Location = new Point(16, 412); lblStatus.AutoSize = true; lblStatus.Anchor = AnchorStyles.Bottom | AnchorStyles.Left; Controls.Add(lblStatus); tray = new NotifyIcon(); tray.Icon = Icon; tray.Text = "截图取字"; tray.Visible = true; ContextMenu menu = new ContextMenu(); menu.MenuItems.Add("打开", (s, e) => { Show(); WindowState = FormWindowState.Normal; }); menu.MenuItems.Add("退出", (s, e) => { tray.Visible = false; Close(); Application.Exit(); }); tray.ContextMenu = menu; Icon = MakeIcon(); tray.Icon = Icon; FormClosing += (s, e) => { if (e.CloseReason == CloseReason.UserClosing) // 点 × 缩到托盘 { e.Cancel = true; Hide(); } }; Load += (s, e) => { RegisterHotKey(Handle, HOTKEY_SNAP, MOD_CONTROL | MOD_ALT, (uint)'O'); }; } class LangItem { public string Tag, Name; public LangItem(string tag, string name) { Tag = tag; Name = name; } public override string ToString() { return Name; } } static Icon MakeIcon() { using (Bitmap b = new Bitmap(32, 32)) using (Graphics g = Graphics.FromImage(b)) { g.Clear(Color.Transparent); using (Pen pen = new Pen(Color.FromArgb(64, 156, 255), 3)) g.DrawRectangle(pen, 2, 2, 27, 27); using (Font f = new Font("Microsoft YaHei", 13, FontStyle.Bold)) TextRenderer.DrawText(g, "文", f, new Rectangle(0, 0, 32, 32), Color.FromArgb(64, 156, 255), TextFormatFlags.HorizontalCenter | TextFormatFlags.VerticalCenter); return Icon.FromHandle(b.GetHicon()); } } void Log(string msg) { lblStatus.Text = DateTime.Now.ToString("HH:mm:ss") + " " + msg; } string LangTag() { return cmbLang.SelectedItem is LangItem ? ((LangItem)cmbLang.SelectedItem).Tag : null; } protected override void WndProc(ref Message m) { const int WM_HOTKEY = 0x0312; if (m.Msg == WM_HOTKEY && m.WParam.ToInt32() == HOTKEY_SNAP) { SnapAndOcr(); return; } base.WndProc(ref m); } void SnapAndOcr() { Hide(); Thread.Sleep(120); // 等主窗口消失再截屏 using (OcrOverlay overlay = new OcrOverlay()) { if (overlay.ShowDialog() != DialogResult.OK || !OcrOps.IsMeaningful(overlay.Result)) { Show(); return; } Rectangle sel = overlay.Result; Rectangle vs = SystemInformation.VirtualScreen; sel.Offset(-vs.X, -vs.Y); Bitmap screen = OcrOps.CaptureScreen(); Bitmap shot = OcrOps.Crop(screen, sel); screen.Dispose(); Recognize(shot, "屏幕 " + sel.Width + "×" + sel.Height); } Show(); } void OnOpenImage(object sender, EventArgs e) { using (OpenFileDialog dlg = new OpenFileDialog()) { dlg.Title = "选择要识别的图片"; dlg.Filter = "图片|*.png;*.jpg;*.jpeg;*.bmp;*.gif;*.webp|全部文件|*.*"; if (dlg.ShowDialog() != DialogResult.OK) return; try { Recognize(new Bitmap(dlg.FileName), Path.GetFileName(dlg.FileName)); } catch (Exception ex) { Log("打开失败:" + ex.Message); } } } void OnClipboardImage() { if (!Clipboard.ContainsImage()) { Log("剪贴板里没有图片"); return; } using (Image img = Clipboard.GetImage()) { Recognize(new Bitmap(img), "剪贴板图片"); } } void Recognize(Bitmap bmp, string sourceName) { Log("正在识别 " + sourceName + " …"); Cursor old = Cursor; Cursor = Cursors.WaitCursor; try { Bitmap up = OcrOps.MaybeScaleUp(bmp); byte[] png = OcrOps.ToPngBytes(up); if (up != bmp) up.Dispose(); List lines = OcrOps.PngToLines(png, LangTag()); if (txtResult.Text.Length > 0) txtResult.AppendText(Environment.NewLine); txtResult.AppendText(string.Join(Environment.NewLine, lines.ToArray())); Clipboard.SetText(txtResult.Text); Log(sourceName + " 识别出 " + lines.Count + " 行,已复制到剪贴板"); } catch (Exception ex) { Log("识别失败:" + ex.Message); } finally { Cursor = old; bmp.Dispose(); } } void CopyResult() { if (txtResult.Text.Length == 0) { Log("还没有结果可复制"); return; } Clipboard.SetText(txtResult.Text); Log("已复制 " + txtResult.Text.Length + " 字"); } /* 自测:不开遮罩、不弹托盘气泡 */ internal bool headless; protected override void SetVisibleCore(bool value) { base.SetVisibleCore(headless ? false : value); } } /* ───────────── 自测 ───────────── */ public static class OcrSelfTest { static int _pass, _fail; static List _lines = new List(); static void Check(string name, object got, object want) { bool ok = string.Equals(got == null ? "" : got.ToString(), want == null ? "" : want.ToString()); if (ok) { _pass++; _lines.Add(" [ok] " + name); } else { _fail++; _lines.Add(" [!!] " + name + " got=" + got + " want=" + want); } } static Bitmap DrawTextImage(int w, int h, string text, int fontSize, string fontName) { Bitmap bmp = new Bitmap(w, h, PixelFormat.Format32bppArgb); using (Graphics g = Graphics.FromImage(bmp)) { g.Clear(Color.White); g.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAliasGridFit; using (Font f = new Font(fontName, fontSize)) g.DrawString(text, f, Brushes.Black, 10, h / 2 - fontSize); } return bmp; } public static int Run(string dir) { _pass = 0; _fail = 0; _lines = new List(); _lines.Add("截图取字 自测 " + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")); string baseDir = string.IsNullOrEmpty(dir) ? Path.Combine(Path.GetTempPath(), "gt-ocr-" + Guid.NewGuid().ToString("N").Substring(0, 8)) : dir; try { Directory.CreateDirectory(baseDir); try { Console.OutputEncoding = Encoding.UTF8; } catch { } // 0. 引擎可用性(本机没装语言包时给出明确信息后跳过识别类断言) List> langs = OcrOps.AvailableLangs(); Check("系统有可用 OCR 语言", langs.Count > 0, true); bool hasEngine = OcrOps.CreateEngine(null) != null; // 1. 中英混合识别(去掉字间空格后比对关键词) if (hasEngine) { using (Bitmap b = DrawTextImage(420, 120, "绿色工具箱 2026", 24, "Microsoft YaHei")) { string pngPath = Path.Combine(baseDir, "zh.png"); b.Save(pngPath, ImageFormat.Png); string text = OcrOps.ImageFileToText(pngPath, "zh-Hans-CN"); Check("中文识别命中", OcrOps.StripSpace(text).Contains("绿色工具箱"), true); Check("数字识别命中", OcrOps.StripSpace(text).Contains("2026"), true); } using (Bitmap b = DrawTextImage(420, 120, "Hello OCR 12345", 22, "Arial")) { string pngPath = Path.Combine(baseDir, "en.png"); b.Save(pngPath, ImageFormat.Png); string text = OcrOps.ImageFileToText(pngPath, "en-US"); Check("英文识别命中", OcrOps.StripSpace(text).ToUpperInvariant().Contains("HELLOOCR"), true); Check("英文数字命中", OcrOps.StripSpace(text).Contains("12345"), true); } // 2. 多行识别:行数 >= 2 且每行关键词都在 Bitmap two = new Bitmap(420, 200, PixelFormat.Format32bppArgb); using (Graphics g = Graphics.FromImage(two)) { g.Clear(Color.White); g.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAliasGridFit; using (Font f = new Font("Microsoft YaHei", 20)) { g.DrawString("第一行甲乙", f, Brushes.Black, 10, 30); g.DrawString("第二行丙丁", f, Brushes.Black, 10, 110); } } List lines = OcrOps.PngToLines(OcrOps.ToPngBytes(two), "zh-Hans-CN"); two.Dispose(); Check("多行识别行数", lines.Count >= 2, true); Check("行内容命中", OcrOps.StripSpace(string.Join("", lines.ToArray())).Contains("甲乙") && OcrOps.StripSpace(string.Join("", lines.ToArray())).Contains("丙丁"), true); // 3. 小图放大逻辑 using (Bitmap small = new Bitmap(200, 100, PixelFormat.Format32bppArgb)) using (Bitmap up = OcrOps.MaybeScaleUp(small)) Check("小图放大 2 倍", up.Width + "x" + up.Height, "400x200"); using (Bitmap big = new Bitmap(1200, 800, PixelFormat.Format32bppArgb)) using (Bitmap same = OcrOps.MaybeScaleUp(big)) Check("大图不放大", same.Width + "x" + same.Height, "1200x800"); } // 4. 裁剪几何 using (Bitmap src = new Bitmap(100, 80, PixelFormat.Format32bppArgb)) using (Graphics g = Graphics.FromImage(src)) { g.Clear(Color.White); using (SolidBrush br = new SolidBrush(Color.Red)) g.FillRectangle(br, 20, 20, 10, 10); } using (Bitmap src2 = new Bitmap(100, 80, PixelFormat.Format32bppArgb)) using (Bitmap crop = OcrOps.Crop(src2, new Rectangle(10, 12, 50, 40))) { Check("裁剪尺寸", crop.Width + "x" + crop.Height, "50x40"); } Check("选区太小无意义", OcrOps.IsMeaningful(new Rectangle(0, 0, 3, 5)), false); Check("正常选区有意义", OcrOps.IsMeaningful(new Rectangle(0, 0, 640, 480)), true); // 5. 空白处理与空输入 Check("去空白", OcrOps.StripSpace(" 绿 色 工 具 箱 "), "绿色工具箱"); try { OcrOps.PngToLines(new byte[0], null); Check("空输入抛异常", false, true); } catch (ArgumentException) { Check("空输入抛异常", true, true); } // 6. Form 层:语言下拉与结果框就绪 OcrForm form = new OcrForm(); form.headless = true; Check("语言下拉有选项", form != null && form.Controls.Count > 0, true); _lines.Add("结果: " + _pass + " 通过, " + _fail + " 失败"); if (hasEngine) _lines.Add("(识别类断言基于系统 OCR 引擎)"); else _lines.Add("(!! 本机无 OCR 语言包,识别类断言已跳过)"); } catch (Exception ex) { _lines.Add("异常: " + ex.GetType().Name + ": " + ex.Message); _fail++; } string all = string.Join("\r\n", _lines.ToArray()); Console.WriteLine(all); try { File.WriteAllText(Path.Combine(Directory.GetCurrentDirectory(), "selftest-ocr.txt"), all, new UTF8Encoding(true)); } catch { } return _fail == 0 ? 0 : 1; } } /* ───────────── 入口 ───────────── */ static class Program { [STAThread] static int Main(string[] args) { if (args.Length >= 1 && args[0] == "--selftest") return OcrSelfTest.Run(args.Length >= 2 ? args[1] : null); if (args.Length >= 1 && (args[0] == "--ocr")) { try { Console.OutputEncoding = Encoding.UTF8; } catch { } string lang = args.Length >= 3 ? args[2] : "zh-Hans-CN"; Console.WriteLine(OcrOps.ImageFileToText(args[1], lang)); return 0; } using (Mutex mutex = new Mutex(true, "GT-OCR-SNAP-单实例")) { if (!mutex.WaitOne(0, false)) return 0; Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new OcrForm()); } return 0; } } }