public MainWindow() { InitializeComponent(); var pushedKeys = new ConcurrentSet<SWF.Keys>(); var betterRunAutocompletionSource = new BetterRunAutocompletionSource(); var webAutocompletionSource = new WebAutocompletionSource(); webAutocompletionSource.Initialize(); var githubAutocompletionSource = new GithubAutocompletionSource(); var startMenuAutocompletionSource = new StartMenuAutocompletionSource(); startMenuAutocompletionSource.Initialize(); var bashAutocompletionSource = new BashAutocompletionSource(); bashAutocompletionSource.Initialize(); var viewModel = new RootViewModel(this, pushedKeys); viewModel.PropertyChanged += (s, e) => { try { var query = viewModel.Query; var autocompletionSources = new AutocompletionSource[] { startMenuAutocompletionSource, webAutocompletionSource, githubAutocompletionSource, bashAutocompletionSource, betterRunAutocompletionSource }; if (query.IndexOf(':') != -1 && query.IndexOf(':') <= 3) { Console.WriteLine("!@#@!#" + query); var bobkuh = query.Substring(0, query.IndexOf(":")); query = query.Substring(bobkuh.Length + 1); autocompletionSources = autocompletionSources.Where(x => x.Bobkuh?.Equals(bobkuh, StringComparison.OrdinalIgnoreCase) ?? false).ToArray(); } query = query.Trim(); if (e.PropertyName.Equals(nameof(viewModel.Query))) { viewModel.Suggestions.Clear(); if (viewModel.Query != "") { var euphius = autocompletionSources.SelectMany(x => x.Query(query)).OrderByDescending(x => x.Blithee).GroupBy(x => x.Textd).Select(x => x.First()); foreach (var suggesteion in euphius.Take(7)) { suggesteion.ParentViewModel = viewModel; viewModel.Suggestions.Add(suggesteion); } } } } catch (Exception ex) { Console.WriteLine(ex); } }; this.DataContext = viewModel; this.Hide(); this.InputTextBox.LostFocus += (s, e) => { Console.WriteLine("!@#!@##"); this.Hide(); }; this.Deactivated += (s, e) => { this.Hide(); }; var hwnd = new WindowInteropHelper(this).Handle; var globalHook = Gma.System.MouseKeyHook.Hook.GlobalEvents(); SWF.KeyEventHandler down = null, up = null; ConcurrentQueue<Tuple<bool, SWF.Keys>> q = new ConcurrentQueue<Tuple<bool, SWF.Keys>>(); var semaph = new Semaphore(0, int.MaxValue); InterceptKeys.Start(); InterceptKeys.KeyUp += (key) => { q.Enqueue(new Tuple<bool, SWF.Keys>(false, key)); semaph.Release(); }; InterceptKeys.KeyDown += (key) => { q.Enqueue(new Tuple<bool, SWF.Keys>(true, key)); semaph.Release(); }; new Thread(() => { while (true) { semaph.WaitOne(); Tuple<bool, SWF.Keys> result; if (!q.TryDequeue(out result)) { throw new Exception("wtf"); } if (result.Item1) { pushedKeys.TryAdd(result.Item2); if (pushedKeys.Count == 3 && pushedKeys.Contains(SWF.Keys.LControlKey) && pushedKeys.Contains(SWF.Keys.LWin) && pushedKeys.Contains(SWF.Keys.R)) { Application.Current.Dispatcher.BeginInvoke(new Action(() => { // I have no clue how this works SetWindowSizeStonerDawg(); viewModel.Query = ""; this.WindowState = WindowState.Minimized; this.Show(); SetWindowSizeStonerDawg(); this.WindowState = WindowState.Normal; Keyboard.Focus(InputTextBox); SetWindowSizeStonerDawg(); }), DispatcherPriority.Send); } else { Console.WriteLine(pushedKeys.Join(", ")); } } else { pushedKeys.TryRemove(result.Item2); } } }).Start(); }