Exemplo n.º 1
0
        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);
            }
        }
Exemplo n.º 2
0
        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);
        }
Exemplo n.º 3
0
 private void switchToWin(IWindowEntry tag)
 {
     WindowToForeground.ForceWindowToForeground(tag.HWnd);
     HideWin();
 }