public void SnapToWindowTimer_Tick(object sender, EventArgs e) { CommunicationData.Overlay.TargetWindowHandle = Win32.FindWindow(null, C_Data.TargetWindowName); Win32.GetWindowRect(CommunicationData.Overlay.TargetWindowHandle, out rect); Win32.GetWindowRect(CommunicationData.Overlay.TargetWindowHandle, out rect); this.Width = rect.right - rect.left; this.Height = rect.bottom - rect.top; this.Top = rect.top; this.Left = rect.left; IntPtr ForegroundWindowHandle = Win32.GetForegroundWindow(); if (ForegroundWindowHandle == this.Handle) { Win32.SetForegroundWindow(CommunicationData.Overlay.TargetWindowHandle); this.Show(); } else if (ForegroundWindowHandle == CommunicationData.Overlay.TargetWindowHandle) { this.Show(); if (CInput.GetKeyStateRightShiftPressed()) { if (cmr_input.GetKeyStateDown(Win32.VirtualKeys.Control)) { Win32.SetForegroundWindow(CommunicationData.Console.Handle); Win32.SetForegroundWindow(CommunicationData.Console.Handle); } else { Win32.SetForegroundWindow(Data.CommunicationData.MainWindow.WindowHandle); } } } else if (ForegroundWindowHandle == CommunicationData.Console.Handle && CInput.GetKeyStateRightShiftPressed() && !cmr_input.GetKeyStateDown(Win32.VirtualKeys.Control)) { Win32.SetForegroundWindow(CommunicationData.Overlay.TargetWindowHandle); this.Hide(); } else { this.Hide(); } }