Textractor github地址:https://github.com/Artikash/Textractor

Textractor 提供 Textractor CLI.exe(控制台版本), 所以直接重定向它的输入输出流即可,使用.Net提供的 System.Diagnostics.Process

 const string Path = @"C:\Textractor\TextractorCLI.exe";
ProcessStartInfo processStartInfo = new ProcessStartInfo()
            {
                UseShellExecute = false,
                CreateNoWindow = true,
                StandardOutputEncoding = Encoding.Unicode,
                FileName = Path,
                RedirectStandardInput = true,
                RedirectStandardOutput = true
            };
            Process Textractor = Process.Start(processStartInfo);
            Textractor.BeginOutputReadLine();
            await Textractor.StandardInput.WriteLineAsync("attach -P14048");
            await Textractor.StandardInput.FlushAsync();
            Textractor.OutputDataReceived += (S, E) => { Console.WriteLine(E.Data); };

但是这样是不行的,能够获取输出,但不能输入,所以查看了源码,最后发现删掉_setmode(_fileno(stdin), _O_U16TEXT); 即可

然后就行了,大功告成


一沙一世界,一花一天堂。君掌盛无边,刹那成永恒。