使用C#代码模拟文本框填充和按钮按下

使用C#代码模拟文本框填充和按钮按下,c#,windows,C#,Windows,我正在开发一个C#程序,它可以自动完成任务。例如,我的程序打开一个外部应用程序(特别是mstsc.exe)并使用该应用程序。我想写一段代码,用特定的值填充文本框并按下特定的按钮。在C#4代码中实现此类操作的正确且最优雅的方法是什么?如果您的特殊目标是mstsc.exe请使用: mstsc.exe[][/v:[:][/admin][/f][/w:/h][/public][/span] mstsc.exe/edit mstsc.exe/migrate else是CodePlex上一个可靠的开源库,

我正在开发一个C#程序,它可以自动完成任务。例如,我的程序打开一个外部应用程序(特别是mstsc.exe)并使用该应用程序。我想写一段代码,用特定的值填充文本框并按下特定的按钮。在C#4代码中实现此类操作的正确且最优雅的方法是什么?

如果您的特殊目标是
mstsc.exe
请使用:

mstsc.exe[][/v:[:][/admin][/f][/w:/h][/public][/span]
mstsc.exe/edit
mstsc.exe/migrate

else是CodePlex上一个可靠的开源库,可供您参考。

我解决这个问题的方法是使用“SendKeys”:

我希望这会有帮助;)

mstsc.exe [<Connection File>] [/v:<Server>[:<Port>]] [/admin] [/f] [/w:<Width> /h:<Height>] [/public] [/span]

mstsc.exe /edit <Connection File>

mstsc.exe /migrate 
var Proc = new System.Diagnostics.Process();
Proc.StartInfo.FileName = "C:\\Windows\\System32\\mstsc.exe";

//Proc.StartInfo.Arguments = "/v:" + "PCwg01"; normaly
Proc.Start();

System.Threading.Thread.Sleep(100);
SendKeys.Send("PCwg01"); //name or IP adress
SendKeys.Send("\r");