Beispiel #1
0
        private void OnHookKeyDown(object sender, HookEventArgs e)
        {
            bool isTrigged = Region(e);
            bool capScreen = Screen(e);

            if (isTrigged)
            {
                if (form.IsDisposed)
                {
                    form = new FormProgram();
                }

                form.Show();
                form.Activate();
                form.TopMost = true;
            }
            else if (capScreen)
            {
                form.Dispose();

                if (form.IsDisposed)
                {
                    form = new FormProgram(true);
                }

                form.Show();
                form.Activate();
                form.TopMost = true;
            }
        }
Beispiel #2
0
        protected override void OnStartup(StartupEventArgs e)
        {
            base.OnStartup(e);

            // Initialize Tray Icon
            trayIcon = new NotifyIcon()
            {
                Icon        = Icon.FromHandle(icon.GetHicon()),
                ContextMenu = new ContextMenu(new MenuItem[] {
                    new MenuItem("Settings", Setting),
                    new MenuItem("Exit", Exit)
                }),
                Visible = true
            };

            ShutdownMode = ShutdownMode.OnExplicitShutdown;
            form         = new FormProgram();
            form.Dispose();

            hook          = new KeyboardHook();
            hook.KeyDown += new KeyboardHook.HookEventHandler(OnHookKeyDown);

            if (Settings.Default.Key == "")
            {
                settingsForm.ShowDialog();
            }
        }