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); 即可

然后就行了,大功告成

Comments | 2 条评论
博主请问,如何传入pid或者句柄?
@s WriteLineAsync这句啊,你也可以使用https://github.com/alexbft/chiitrans的方法把cli.exe,改为dll,c#调用