private void Instance_HeadMovement(object sender, HeadMovementEventArgs e) { this.Dispatcher.Invoke((Action)(() => { this.detectionTextBox.Text = e.Gesture; })); }
private void HandleHeadMovement(object sender, HeadMovementEventArgs e) { String gesture = e.Gesture; if (gesture.Equals(Gesture.Pitch.Down)) { // reserve this gesture for mouse clicks uint x = (uint)System.Windows.Forms.Cursor.Position.X; uint y = (uint)System.Windows.Forms.Cursor.Position.Y; mouse_event(MOUSEEVENTF_LEFTDOWN | MOUSEEVENTF_LEFTUP, x, y, 0, 0); } else { // get window title IntPtr handle = GetForegroundWindow(); int length = GetWindowTextLength(handle) + 1; StringBuilder title = new StringBuilder(length); GetWindowText(handle, title, title.Capacity); // get processes Process[] pl = Process.GetProcesses(); foreach (Process p in pl) { // find the process for the active window if (p.MainWindowHandle == handle) { Dictionary <String, String> map = Settings.Instance.HeadMovement.GetMapping(p.ProcessName); if (map != null) { String sequence = map[gesture]; SendKeys.SendWait(keySequence.Parse(sequence)); } } } } }
private void OnHeadMovement(HeadMovementEventArgs e) { if (HeadMovement != null) { HeadMovement(this, e); } }