Exemplo n.º 1
0
        static void mi_Click(object sender, EventArgs e)
        {
            MenuItem item = (MenuItem)sender;

            if (item != null)
            {
                PreviewWindow win = (PreviewWindow)item.Tag;
                if (win != null)
                {
                    win.KIllTimer();
                    Debug.WriteLine("Showing (click): " + win.Handle.ToString());
                    BringWindowToTop(win.Handle);
                }
            }
        }
Exemplo n.º 2
0
        static void win_Disposed(object sender, EventArgs e)
        {
            PreviewWindow win = (PreviewWindow)sender;

            windows.Remove(win);

            for (int i = 0; i < mnu.MenuItems.Count; i++)
            {
                if (mnu.MenuItems[i].Tag == (object)win)
                {
                    mnu.MenuItems.RemoveAt(i);
                    break;
                }
            }

            if (windows.Count == 0)
            {
                _sep.Visible = false;
            }

            Debug.WriteLine("Removing Window...");
        }
Exemplo n.º 3
0
        static void hook_KeyPressed(object sender, KeyPressedEventArgs e)
        {
            IntPtr pWin = IntPtr.Zero;

            /*
             * if (e.Key == Keys.Z && e.Modifier == (KBModifierKeys.Win | KBModifierKeys.Shift))
             * {
             *  Debug.WriteLine("Got WinShiftZ");
             *  Point p = new Point();
             *  bool hr = GetCursorPos(out p);
             *
             *  if (hr)
             *  {
             *      Debug.WriteLine("Got Cursor Pos");
             *      pWin = WindowFromPoint(p);
             *      if (pWin == IntPtr.Zero)
             *      {
             *          Debug.WriteLine("WindowFromPoint Failed");
             *          pWin = GetForegroundWindow();
             *      }
             *  }
             *  else
             *  {
             *      pWin = GetForegroundWindow();
             *  }
             *
             * }
             * else
             * {
             *  Debug.WriteLine("Got WinZ");
             *  pWin = GetForegroundWindow();
             * }
             */

            pWin = GetForegroundWindow();

            if (pWin == IntPtr.Zero)
            {
                Debug.WriteLine("Bad Window - Not Adding");
                return;
            }

            string title = GetText(pWin);



            PreviewWindow win = new PreviewWindow(pWin);

            win.Disposed += new EventHandler(win_Disposed);

            MenuItem mi = new MenuItem();

            mi.Tag    = win;
            mi.Text   = "Window: " + title;
            mi.Click += new EventHandler(mi_Click);
            mnu.MenuItems.Add(0, mi);

            windows.AddLast(win);
            Debug.WriteLine("Adding Window... ");
            _sep.Visible = true;
        }
Exemplo n.º 4
0
        static void hook_KeyPressed(object sender, KeyPressedEventArgs e)
        {
            IntPtr pWin = IntPtr.Zero;
            /*
            if (e.Key == Keys.Z && e.Modifier == (KBModifierKeys.Win | KBModifierKeys.Shift))
            {
                Debug.WriteLine("Got WinShiftZ");
                Point p = new Point();
                bool hr = GetCursorPos(out p);

                if (hr)
                {
                    Debug.WriteLine("Got Cursor Pos");
                    pWin = WindowFromPoint(p);
                    if (pWin == IntPtr.Zero)
                    {
                        Debug.WriteLine("WindowFromPoint Failed");
                        pWin = GetForegroundWindow();
                    }
                }
                else
                {
                    pWin = GetForegroundWindow();
                }

            }
            else
            {
                Debug.WriteLine("Got WinZ");
                pWin = GetForegroundWindow();
            }
            */

            pWin = GetForegroundWindow();

            if (pWin == IntPtr.Zero)
            {
                Debug.WriteLine("Bad Window - Not Adding");
                return;
            }

            string title = GetText(pWin);

            PreviewWindow win = new PreviewWindow(pWin);
            win.Disposed += new EventHandler(win_Disposed);

            MenuItem mi = new MenuItem();
            mi.Tag = win;
            mi.Text = "Window: " + title;
            mi.Click += new EventHandler(mi_Click);
            mnu.MenuItems.Add(0, mi);

            windows.AddLast(win);
            Debug.WriteLine("Adding Window... ");
            _sep.Visible = true;
        }