[英]How to maximize/ minimize currently opened Firefox window through C#
[英]how can minimize and maximize window folders in C#
我正在嘗試最小化帶有語音(語音識別)的窗口文件夾和應用程序,這是我的代碼:
[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);
}
我知道如何在按鈕上使用該代碼,但是我不知道如何在語音識別中使用它,因此,如何最小化帶有語音的窗口? 謝謝。
首先,您需要注冊以下語音識別事件:頁面加載
// Register handler for the SpeechRecognized event. recognizer.SpeechRecognized += new EventHandler<SpeechRecognizedEventArgs>(srEvent_SpeechRecognized);
然后創建語音識別事件處理程序,例如:
void srEvent_SpeechRecognized(object sender, SpeechRecognizedEventArgs e) { this.WindowState = FormWindowState.Minimized; }
您可能需要看看Microsoft.Speech.Recognition.SpeechRecognitionEngine 。 使用此功能,您可以訂閱事件並繼續執行想要對這些事件執行的任何操作。 在https://msdn.microsoft.com/zh-cn/library/hh378426(v=office.14).aspx上獲取更多信息。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.