示例#1
0
 private static void OnHotKeyPressed(Hot_Key_Event_Args eventargs1)
 {
     if (HotKeyPressed != null)
     {
         HotKeyPressed(null, eventargs1);
     }
 }
示例#2
0
 protected override void WndProc(ref Message m)
 {
     if (m.Msg == WM_HOTKEY)
     {
         var eevent = new Hot_Key_Event_Args(m.LParam);
         OnHotKeyPressed(eevent);
     }
     base.WndProc(ref m);
 }
示例#3
0
        private static void HotKeyManager_HotKeyPressed(object sender, Hot_Key_Event_Args eventargs)
        {
            if (eventargs.Modifiers != ModifierKey)
            {
                return;
            }

            switch (eventargs.Key)
            {
            case Keys.K: {
                Process p = GetActiveProcess();
                Console.WriteLine("Killing " + p.ProcessName + "...");
                p.Kill();
                break;
            }

            case Keys.S: {
                Process p           = GetActiveProcess();
                bool    isSuspended = p.Threads[0].WaitReason == ThreadWaitReason.Suspended;

                if (isSuspended)
                {
                    Console.WriteLine("Resuming " + p.ProcessName + "...");
                    ResumeProcess(p);
                }
                else
                {
                    Console.WriteLine("Suspending " + p.ProcessName + "...");
                    SuspendProcess(p);
                }

                break;
            }

            //case Keys.R: {

            //    Process p = GetActiveProcess();
            //    Console.WriteLine("Resuming " + p.ProcessName + "...");
            //    ResumeProcess(p);
            //    break;
            //}

            case Keys.Q:
                Console.WriteLine("Quitting...");
                Environment.Exit(1);
                break;

            case Keys.H:

                isShow = !isShow;

                var handle = GetConsoleWindow();
                ShowWindow(handle, isShow ? SW_SHOW : SW_HIDE);
                break;
            }
        }