我们怎样才能让 Windows 窗体应用程序的事件等待用户输入?
就像我命令我的电脑关机或注销或休眠或睡眠一样,它会确认我真的想关机/注销或休眠或睡眠,如果我说是,则执行操作,否则它会执行,如果我拒绝或说abort 它将中止该操作。
但不仅仅是在没有确认的命令后直接关闭电脑。
我正在通过语音命令系统在语音识别计算机中使用它 我不希望出现消息框并问我是或否 我让它说话并问我是否要这样做但它没有等待我的回答。
当前代码:
string speech = e.Result.Text.ToString();
string[] terminateFind = speech.Split(' ');
if (terminateFind[0]=="Terminate"||terminateFind[0]=="Kill")
{
speech = "";
for (int i = 0; i < terminateFind.Length-1; i++)
{
speech += terminateFind[i]+" ";
}
KillingProcess = Int32.Parse(terminateFind[terminateFind.Length-1]);
}
switch (speech) {
case "Terminate Process Number ":
case "Kill Process Number ":
case "Close Process Number ":
string Procr = listBox1.Items[KillingProcess - 1].ToString();
string[]Kilproc = Procr.Split('-');
int Pid = Process.GetProcessesByName(ProcName[KillingProcess - 1])[0].Id;
Travis.Speak("Terminating Porcess named : " + Kilproc[Kilproc.Length - 1]);
Thread.Sleep(10000);
// sRecog.SpeechRecognized += new EventHandler<SpeechRecognizedEventArgs>(sRecog_SpeechRecognized);
if (e.Result.Text.ToString() == "Abort") {
AbortTheComand = true;
}
if (AbortTheComand == false) {
Process.GetProcessById(Pid, ".").Kill();
} else {
Travis.Speak("Operation Terminated by user : ");
}
break;
}