我正在尝试用语音(语音识别)最小化窗口文件夹和应用程序,这是我的代码:
[DllImport("user32.dll")]
[return: MarshalAs(UnmanagedType.Bool)]
static extern bool GetWindowPlacement(IntPtr hWnd, ref WINDOWPLACEMENT lpwndpl);
[DllImport("user32.dll", SetLastError = true)]
static extern IntPtr FindWindow(string lpClassName, string lpWindowName);
[DllImport("user32.dll")]
static extern bool SetWindowPlacement(IntPtr hWnd, ref WINDOWPLACEMENT lpwndpl);
private struct POINTAPI
{
public int x;
public int y;
}
private struct RECT
{
public int left;
public int top;
public int right;
public int bottom;
}
private struct WINDOWPLACEMENT
{
public int length;
public int flags;
public int showCmd;
public POINTAPI ptMinPosition;
public POINTAPI ptMaxPosition;
public RECT rcNormalPosition;
}
private void button1_Click(object sender, EventArgs e)
{
WindowAction_MinimizeNotepad();
}
void WindowAction_MinimizeNotepad()
{
System.IntPtr app_hwnd;
WINDOWPLACEMENT wp = new WINDOWPLACEMENT();
app_hwnd = FindWindow("chrome", null);
GetWindowPlacement(app_hwnd, ref wp);
wp.showCmd = 2;
SetWindowPlacement(app_hwnd, ref wp);
}我知道如何使用带有按钮的代码,但我不知道如何将它用于语音识别,那么,如何最小化带有语音的窗口呢?谢谢。
发布于 2016-04-25 20:56:23
首先,您需要注册语音识别事件,如: On Page load
// Register handler for the SpeechRecognized event. recognizer.SpeechRecognized += new EventHandler<SpeechRecognizedEventArgs>(srEvent_SpeechRecognized);
然后创建语音识别事件处理程序,如下所示:
void srEvent_SpeechRecognized(object sender, SpeechRecognizedEventArgs e) { this.WindowState = FormWindowState.Minimized; }
发布于 2016-04-25 21:39:51
你可能想看看Microsoft.Speech.Recognition.SpeechRecognitionEngine.使用它,您可以订阅事件并继续对这些事件执行您想要执行的任何操作。欲了解更多信息,请访问https://msdn.microsoft.com/en-us/library/hh378426(v=office.14).aspx。
https://stackoverflow.com/questions/36825450
复制相似问题