Ejemplo n.º 1
0
        void handleProcessComboSelectedIndexChanged(object sender, EventArgs e)
        {
            this.notifyIcon.ContextMenuStrip.Hide();
            var combo = (ToolStripComboBox)sender;
            this.processWrapper = (ProcessWrapper)combo.SelectedItem;
            if (this.processWrapper.Windowname.Length > 64) {
                this.notifyIcon.Text = this.processWrapper.Windowname.Substring(1, 63);
            } else {
                this.notifyIcon.Text = this.processWrapper.Windowname;
            }
            combo = null;

            this.processWrapper.ToggleTaskbarButton();

            setIcon(true);
            this.trackBarHost.Visible = true;
        }
Ejemplo n.º 2
0
 private void populateCombo(ToolStripComboBox combo)
 {
     combo.Items.Clear();
     foreach (var p in System.Diagnostics.Process.GetProcesses()) {
         if (p.MainWindowTitle == string.Empty) {
             continue;
         }
         var pw = new ProcessWrapper()
         {
             Handle = p.MainWindowHandle,
             Windowname = p.MainWindowTitle
         };
         combo.Items.Add(pw);
     }
 }
Ejemplo n.º 3
0
        public ToTryHandler(IntPtr handle)
        {
            this.notifyIcon = new NotifyIcon();
            this.notifyIcon.Icon = Properties.Resources.Icon;
            this.notifyIcon.ContextMenuStrip = new ContextMenuStrip();
            this.notifyIcon.ContextMenuStrip.ShowCheckMargin = false;
            this.notifyIcon.ContextMenuStrip.ShowImageMargin = false;
            this.notifyIcon.Visible = true;
            this.notifyIcon.MouseClick += handleNotifyIconMouseClick;
            this.notifyIcon.DoubleClick += handleNotifyIconDoubleClick;

            this.localWindowsHook = new LocalWindowsHook(HookType.WH_KEYBOARD_LL);
            this.localWindowsHook.HookInvoked += handleHookInvoked;
            this.localWindowsHook.Install();

            populateContextMenu();

            if (!(handle == IntPtr.Zero)) {
                this.processWrapper = new ProcessWrapper();
                this.processWrapper.Handle = handle;
                this.processWrapper.ToggleTaskbarButton();
                this.processWrapper.ToggleVisibility();
                setIcon(true);
                this.trackBarHost.Visible = true;
            }
        }