我基於特徵的事件,如編碼自動安裝程序:自動安裝點擊繼續等,而process.waitforexit()是活躍
- 易編碼的自動安裝,(但以極大的努力在所有程序上工作)。
現在有一個問題,我卡住了,至於如何執行sendkeys等,而程序是在process.waitforexit()
?
try
{
foreach (string checkedItem in checkedListBox1.CheckedItems)
{
if (checkedItem.Contains("."))
{
string str = checkedItem;
if (str.Contains("."))
{
/* haal de rest achter de . eraf om een map ervan te maken. */
int index = str.IndexOf('.');
string folder = str.Substring(0, index);
string pad = Application.StartupPath;
try
{
/* Start de programma. */
bool started = false;
var process = new Process();
process.StartInfo.FileName = pad + "/data/" + folder + "/" + checkedItem;
started = process.Start();
/* Haal de informatie op van de programma's die opgestart worden. */
var processID = process.Id;
var processNAAM = process.ProcessName;
textBox1.Text += "Gevonden - ID: " + processID + " NAAM: " + processNAAM + Environment.NewLine;
textBox1.Text += DateTime.Now.ToString("HH:mm:ss", System.Globalization.DateTimeFormatInfo.InvariantInfo) + " - " + "Installatie Keuze wordt opgestart." + Environment.NewLine;
/* Wacht totdat het programma klaar is! */
process.WaitForExit();
textBox1.Text += DateTime.Now.ToString("HH:mm:ss", System.Globalization.DateTimeFormatInfo.InvariantInfo) + " - " + "Installatie Geslaagd!" + Environment.NewLine + Environment.NewLine;
}
如果有人能夠幫助我在這裏,它會被很多讚賞:d
你(main-)線程在等待的過程中,當阻塞。也許你應該創建一個後臺線程來監視輸入。 – 2013-02-18 13:43:55