public void Gesture_DragMove(object sender, EventArgs e) { HandMouseState = HandMouseStates.WINDOW_DRAG; WindowDragData.resetOldHand = true; window = Win32.GetForegroundWindow(); physWindow = new PhysWindow(window); }
/// <summary> /// Handler for recognized speech events. /// </summary> /// <param name="sender">object sending the event.</param> /// <param name="e">event arguments.</param> private void SpeechRecognized(object sender, SpeechRecognizedEventArgs e) { processNameMap = new Dictionary<String, IntPtr>(); Process[] processlist = Process.GetProcesses(); foreach (Process process in processlist) { if (!String.IsNullOrEmpty(process.MainWindowTitle)) { //Console.WriteLine(process.MainWindowTitle); processNameMap.Add(process.MainWindowTitle, process.MainWindowHandle); } } // Speech utterance confidence below which we treat speech as if it hadn't been heard const double ConfidenceThreshold = 0.3; if (e.Result.Confidence >= ConfidenceThreshold) { Console.WriteLine(e.Result.Text); bool snapOn = false; if (e.Result.Text.ToUpper().Contains("SNAP")) { snapOn = true; window = IntPtr.Zero; foreach (String key in processNameMap.Keys) { if (key.ToUpper().Contains(e.Result.Words[1].Text.ToUpper())) { window = processNameMap[key]; } } } if (window == IntPtr.Zero) { window = Win32.GetForegroundWindow(); foreach (String key in processNameMap.Keys) { Console.WriteLine(key); } } if (snapOn) { physWindow = null; Rect workArea = System.Windows.SystemParameters.WorkArea; if (e.Result.Text.ToUpper().Contains("LEFT")) { Win32.SetForegroundWindow(window); Win32.ShowWindow(window, Win32.SW_RESTORE); Win32.SetWindowPos(window, new IntPtr(0), 0, 0, (int)workArea.Width / 2, (int)workArea.Height, Win32.SetWindowPosFlags.SWP_SHOWWINDOW); } if (e.Result.Text.ToUpper().Contains("RIGHT")) { Win32.SetForegroundWindow(window); Win32.ShowWindow(window, Win32.SW_RESTORE); Win32.SetWindowPos(window, new IntPtr(0), (int)workArea.Width / 2, 0, (int)workArea.Width / 2, (int)workArea.Height, Win32.SetWindowPosFlags.SWP_SHOWWINDOW); } if (e.Result.Text.ToUpper().Contains("UP")) { Win32.SetForegroundWindow(window); Win32.ShowWindow(window, Win32.SW_RESTORE); Win32.SetWindowPos(window, new IntPtr(0), 0, 0, (int)workArea.Width, (int)workArea.Height, Win32.SetWindowPosFlags.SWP_SHOWWINDOW); } if (e.Result.Text.ToUpper().Contains("DOWN")) { Win32.ShowWindow(window, Win32.SW_MINIMIZE); } } if (e.Result.Words[e.Result.Words.Count - 1].Text.ToUpper() == "GRAB") { window = Win32.GetForegroundWindow(); Gesture_DragMove(null, null); } else if (e.Result.Text.ToUpper().Contains("GRAB")) { foreach (String key in processNameMap.Keys) { Rect workArea = System.Windows.SystemParameters.WorkArea; if (key.ToUpper().Contains(e.Result.Words[e.Result.Words.Count - 1].Text.ToUpper())) { window = processNameMap[key]; Gesture_DragMove(null, null); } } } if (e.Result.Text.ToUpper().Contains("DROP IT")) { HandMouseState = HandMouseStates.NONE; } if (e.Result.Text.ToUpper().Contains("MOUSE MODE")) { Gesture_MouseMove(null, null); } if (e.Result.Text.ToUpper().Contains("CLICK")) { Gesture_KnockRecognized(null, null); Gesture_KnockPullRecognized(null, null); } else if (e.Result.Text.ToUpper().Contains("DOUBLE CLICK")) { Gesture_PokeRecognized(null, null); } else if (e.Result.Text.ToUpper().Contains("RIGHT CLICK")) { Gesture_SlapRecognized(null, null); } if (e.Result.Text.ToUpper().Contains("LETS HACK")) { Gesture_ShowAll(null, null); } else if (e.Result.Text.ToUpper().Contains("SHUT IT DOWN")) { Gesture_HideAll(null, null); } } }