在 C# 控制台应用程序中编辑文本? [英] Edit text in C# console application?
本文介绍了在 C# 控制台应用程序中编辑文本?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
有没有办法在 C# 控制台应用程序中编辑文本?换句话说,是否可以在命令行中放置预定义的文本,以便用户可以修改文本,然后重新提交给应用程序?
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();
}
注意:这仅适用于活动窗口.
这篇关于在 C# 控制台应用程序中编辑文本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文