private void OnKeyPressed(object sender, GlobalKeyboardHookEventArgs e) { if (!(e.KeyboardState == GlobalKeyboardHook.KeyboardState.SysKeyDown && GlobalKeyboardHook.WinAltPressed)) { return; } var win = new WindowManipulation(); switch (e.KeyboardData.Key) { case Keys.I: { win.PlaceWindow(2, 0, 3, 1); e.Handled = true; break; } case Keys.U: { win.PlaceWindow(0, 0, 1, 1); e.Handled = true; break; } case Keys.N: { win.PlaceWindow(0, 2, 1, 3); e.Handled = true; break; } case Keys.M: { win.PlaceWindow(2, 2, 3, 3); e.Handled = true; break; } case Keys.J: { win.PlaceWindow(1, 1, 2, 2); e.Handled = true; break; } case Keys.K: { win.PlaceWindow(1, 0, 2, 2); e.Handled = true; break; } case Keys.H: { win.PlaceWindow(0, 0, 2, 2); e.Handled = true; break; } case Keys.L: { win.PlaceWindow(2, 0, 3, 2); e.Handled = true; break; } case Keys.Enter: { _mainWindow.DetectWindowSize(); _mainWindow.Show(); e.Handled = true; break; } } }
public ConfigurationPage() { InitializeComponent(); // Essentially i want to find a way to capture a window live while hardly using the CPU or not using it at all (GPU Accelerated) // Capture the DirectX/OpenGL/Vulkan back buffer? // May try to re-engineer this for my needs -> https://github.com/hecomi/uDesktopDuplication t.Elapsed += ((object sender, ElapsedEventArgs args) => { Common.Window.Dispatcher.InvokeAsync((() => { try { if (WindowManipulation.IsMinimized(WindowInstanceManager.SelectedWindowInstance.InstanceProcess.MainWindowHandle)) { if (!IsWindowMinimized) { WindowVisualRepresentation.Source = new BitmapImage(new Uri("C:\\Windows\\Web\\Wallpaper\\Windows\\img0.jpg")); IsWindowMinimized = true; } } else { IsWindowMinimized = false; try { WindowVisualRepresentation.Source = ImageConversion.ImageSourceForBitmap(WindowManipulation.PrintWindow(WindowInstanceManager.SelectedWindowInstance.InstanceProcess.MainWindowHandle)); } catch (ArgumentException) { WindowVisualRepresentation.Source = new BitmapImage(new Uri("C:\\Windows\\Web\\Wallpaper\\Windows\\img0.jpg")); } } } catch (Exception) { Common.Window.SetCurrentView(NavigationButtons.Window_Selection); } })); }); Unloaded += ((object sender, RoutedEventArgs args) => { t.Stop(); }); t.Interval = TimeSpan.FromSeconds(0.2D).TotalMilliseconds; t.Start(); CurrentProfile.Text = WindowInstanceManager.SelectedWindowInstance.InstanceProcess.MainWindowTitle; Icon i = Icon.ExtractAssociatedIcon(WindowInstanceManager.SelectedWindowInstance.InstanceProcess.MainModule.FileName); if (i != null) { AppIcon.Source = ImageConversion.ToImageSource(i); } else { AppIcon.Source = ImageConversion.ToImageSource(Icon.FromHandle(SystemIcons.Application.Handle)); } if (!WindowInstanceManager.SaveProfileContainer.Profiles.ContainsKey(WinAPI.GetWindowClassName(WindowInstanceManager.SelectedWindowInstance.InstanceProcess.MainWindowHandle))) { WindowInstanceManager.SaveProfileContainer.Profiles.Add(WinAPI.GetWindowClassName(WindowInstanceManager.SelectedWindowInstance.InstanceProcess.MainWindowHandle), new WindowInstanceSaveProfile()); } WindowInstanceManager.SelectedWindowInstance.ListItem.HasProfileImage.Visibility = Visibility.Visible; FileIO.SaveProfiles(WindowInstanceManager.SaveProfileContainer); }