private void OnKeyPressed(GlobalKeyPressed obj) { if (currentShortcutWindow != null || currentArgumentsWindow != null) { switch (obj.Key) { case 0x0000001B: //Escape obj.ProcessKey = false; CloseShortcutWindow(); CloseArgumentWindow(); break; case 0x00000028: //Down shortcutViewModel?.IncrementSelection(1); break; case 0x00000026: //Up shortcutViewModel?.IncrementSelection(-1); break; case 0x0000000D: //Enter obj.ProcessKey = false; //If the current shortcut window is open and doesn't have args, then execute it if (currentShortcutWindow != null && !IsArgumentShortcut()) { shortcutViewModel.ExecuteSelection(); CloseShortcutWindow(); break; } //If the arg window is open and it's not filled out then open the arg window if (currentArgumentsWindow != null && IsArgumentShortcut() && !IsArgumentShortcutFilled()) { argumentsViewModel.ExecuteArgument(); var command = argumentsViewModel.Command; var arguments = GetArgs(); CloseArgumentWindow(); if (arguments.Count() <= shortcutExecutor.Arguments.Count) { shortcutExecutor.Execute(command.Title, command); break; } var argumentKey = arguments.ElementAt(shortcutExecutor.Arguments.Count); argumentsViewModel.Command = command; argumentsViewModel.ArgumentKey = argumentKey; if (IsArgumentShortcutFilled()) { break; } OpenArgumentWindow(); } //If the shortcut window is open and it has args, then open the arg window if (currentShortcutWindow != null && IsArgumentShortcut() && !IsArgumentShortcutFilled()) { var command = shortcutViewModel.SelectedItem.Value; var argumentKey = GetArgs().ElementAt(shortcutExecutor.Arguments.Count); CloseShortcutWindow(); argumentsViewModel.Command = command; argumentsViewModel.ArgumentKey = argumentKey; OpenArgumentWindow(); break; } //if the arg window is open and it's filled out, then execute the shortcut if (currentArgumentsWindow != null && IsArgumentShortcut() && IsArgumentShortcutFilled()) { argumentsViewModel.Execute(); CloseArgumentWindow(); break; } break; } } else if (Keyboard.Modifiers == (settingsViewModel.Modifier1 | settingsViewModel.Modifier2) && obj.Key == (int)settingsViewModel.Key) //Space { currentShortcutWindow = new ShortcutWindow(); currentShortcutWindow.DataContext = shortcutViewModel; currentShortcutWindow.Show(); currentShortcutWindow.Activate(); obj.ProcessKey = false; shortcutViewModel.Reset(); } }