Пример #1
0
 private void Hooker_GlobalHotKeyInvoked()
 {
     if (m_selector != null && (m_selector.Visibility != Visibility.Visible || !m_selector.IsActive))
     {
         m_selector.Close();
         m_selector = null;
     }
     if (m_selector == null)
     {
         OpenWindow();
     }
     else
     {
         m_selector.Close();
         m_selector = null;
     }
 }
Пример #2
0
        private void OpenWindow()
        {
            m_selector = new GifSelector();
            m_selector.ShowInTaskbar = false;
            m_selector.Show();
            m_selector.Activate();
            m_selector.Focus();
            m_selector.Topmost = true;
            m_selector.Topmost = false;
            m_selector.Topmost = true;

            // Try to force focus.
            try
            {
                Window window = Window.GetWindow(m_selector);
                var    wih    = new WindowInteropHelper(window);
                IntPtr hWnd   = wih.Handle;
                SwitchToThisWindow(hWnd, true);
            }
            catch { }
        }