Ejemplo n.º 1
0
        private ProgramForm(bool startup, String processName)
        {
            _startup     = startup;
            _processName = processName;

            _wmShowMe = ProgramForm.RegisterShowMe(_processName);

            String condition = @"TargetInstance ISA 'Win32_Process' 
                             AND TargetInstance.Name = '{processName}'".Inject(new { processName = _processName });

            _watcher = new ManagementEventWatcher(new WqlEventQuery("__InstanceCreationEvent", new TimeSpan(10), condition));
            _watcher.Options.Timeout = new TimeSpan(0, 1, 0);
            _watcher.EventArrived   += Watcher_EventArrived;
            _watcher.Start();

            _notifyIcon                  = new NotifyIcon();
            _notifyIcon.Icon             = this.Icon;
            _notifyIcon.Text             = "Tabbed Anything";
            _notifyIcon.Visible          = true;
            _notifyIcon.DoubleClick     += NotifyIcon_DoubleClick;
            _notifyIcon.ContextMenuStrip = new ContextMenuStrip();

            ToolStripItem openItem = _notifyIcon.ContextMenuStrip.Items.Add("Open");

            openItem.Click += OpenNotifyIconMenuItem_Click;
            ToolStripItem exitItem = _notifyIcon.ContextMenuStrip.Items.Add("Exit");

            exitItem.Click += ExitNotifyIconMenuItem_Click;

            this.FormClosing += ProgramForm_FormClosing;

            this.CreateHandle();
        }
Ejemplo n.º 2
0
        public static void ShowMe(String processName)
        {
            int wmShowMe = ProgramForm.RegisterShowMe(processName);

            Native.PostMessage((IntPtr)Native.HWND_BROADCAST, wmShowMe, IntPtr.Zero, IntPtr.Zero);
        }