在C#控制台应用程序编辑的文本?控制台、应用程序、文本、编辑

2023-09-04 00:14:27 作者:幻影

可能重复:    C#高级控制台I / O

有没有办法来编辑在C#控制台应用程序的文本?换句话说,有没有可能把pre定义的文本在命令行上,以便用户可以修改文本,然后将其重新提交的应用程序?

Is there a way to edit text in a C# console application? In other words, is it possible to place pre-defined text on the command line so that the user can modify the text and then re-submit it to the app?

推荐答案

一件事。 而且采用的SendKeys一个简单的例子:

One thing that came to my mind is to...simulate keystrokes. And a simple example using SendKeys:

static void Main(string[] args)
{
    Console.Write("Your editable text:");
    SendKeys.SendWait("hello"); //hello text will be editable :)
    Console.ReadLine();
}

注意:这仅适用于当前窗口