我尝试使用语音(语音识别)最小化窗口文件夹和应用程序,这是我的代码:
[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);
}
我知道如何将该代码与按钮一起使用,但我不知道如何将其与语音识别一起使用,那么,如何才能最大限度地减少带语音的窗口?感谢。
答案 0 :(得分:0)
首先您需要注册语音识别事件,例如: 在页面加载
// Register handler for the SpeechRecognized event.
recognizer.SpeechRecognized += new EventHandler<SpeechRecognizedEventArgs>(srEvent_SpeechRecognized);
然后创建一个语音识别事件处理程序,如:
void srEvent_SpeechRecognized(object sender, SpeechRecognizedEventArgs e)
{
this.WindowState = FormWindowState.Minimized;
}
答案 1 :(得分:0)
您可能需要查看 Microsoft.Speech.Recognition.SpeechRecognitionEngine 。 使用此功能,您可以订阅事件并继续执行您要对这些事件执行的任何操作。 在https://msdn.microsoft.com/en-us/library/hh378426(v=office.14).aspx
获取更多信息