|
|
|
@ -28,6 +28,41 @@ namespace WpfApp1.WinOcr
|
|
|
|
|
retxt = modiImage.Layout.Text;
|
|
|
|
|
*/
|
|
|
|
|
return retxt;
|
|
|
|
|
/*
|
|
|
|
|
string processName = "notepad"; // 替换为要跟踪的进程名称
|
|
|
|
|
Process[] processes = Process.GetProcessesByName(processName);
|
|
|
|
|
if (processes.Length > 0)
|
|
|
|
|
{
|
|
|
|
|
Process process = processes[0];
|
|
|
|
|
IntPtr hwnd = process.MainWindowHandle;
|
|
|
|
|
var Ocr = new IronTesseract();
|
|
|
|
|
OcrResult Result = null;
|
|
|
|
|
Ocr.TextAvailable += (s, e) =>
|
|
|
|
|
{
|
|
|
|
|
Console.WriteLine(e.Text);
|
|
|
|
|
Result = e.Result;
|
|
|
|
|
};
|
|
|
|
|
while (true)
|
|
|
|
|
{
|
|
|
|
|
if (hwnd != IntPtr.Zero)
|
|
|
|
|
{
|
|
|
|
|
int length = GetWindowTextLength(hwnd);
|
|
|
|
|
if (length > 0)
|
|
|
|
|
{
|
|
|
|
|
IntPtr buffer = Marshal.AllocHGlobal(length + 1);
|
|
|
|
|
GetWindowText(hwnd, buffer, length + 1);
|
|
|
|
|
string text = Marshal.PtrToStringAnsi(buffer);
|
|
|
|
|
Marshal.FreeHGlobal(buffer);
|
|
|
|
|
Ocr.Read(text);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
Console.WriteLine("找不到进程:{0}", processName);
|
|
|
|
|
}
|
|
|
|
|
*/
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void DirExists()
|
|
|
|
|