public void ShowFront() { if (!isShow) { resetData(); if (mWins != null && mWins.Windows.Count > 0) { isShow = true; Activate(); Show(); // 需要确保显示 IntPtr hwnd = new System.Windows.Interop.WindowInteropHelper(this).Handle; WindowToForeground.SetForegroundWindowInternal(hwnd); if (mFocusBtn != null) { mFocusBtn.Focus(); } } } else { // 接收 alt + tab 和 alt + shift +tab和 alt + esc按键 onHotkeyEvent((Key)KeyboardHookAlt.StaticKey, Key.Enter); } }
private bool HideWindowIfNotForeground() { if (_mainWindowEntry?.IsForeground() ?? false) { return(false); } #if (DEBUG) var foregroundWindow = WindowEntryFactory.Create(WindowToForeground.GetForegroundWindow()); Log.DebugFormat("Window does not have focus when initialization is complete. Current foreground window is {0} (Process '{1}')", foregroundWindow.HWnd, foregroundWindow.ProcessName); #endif Hide(false); return(true); }
private void switchToWin(IWindowEntry tag) { WindowToForeground.ForceWindowToForeground(tag.HWnd); HideWin(); }