예제 #1
0
        private PSHotKeyManager()
        {
            // the powershell window may not actually be focused when
            // this cmdlet is run so derive the window handle from the PID.
            Process self = Process.GetCurrentProcess();

            _owner      = self.MainWindowHandle;
            _pid        = self.Id;
            _keyHandler = new PSEventingKeyHandler(true);
        }
예제 #2
0
        private void KeyListener()
        {
            EventHandler idleHandler = new EventHandler(Application_Idle);

            Application.Idle += idleHandler;
            try
            {
                // hook
                using (PSEventingKeyHandler keyHandler = new PSEventingKeyHandler(true))
                {
                    // start a message loop
                    Application.Run();
                } // unhook (same thread)
            }
            finally
            {
                Application.Idle -= idleHandler;
            }
        }