Esempio n. 1
0
        public void SetKeyboardHook(IntPtr hWnd)
        {
#if DEBUG
            // Set keyboard hook only when not debugging, because it slows down jumping through code using the keyboard.
            return;
#endif
#pragma warning disable CS0162 // Unreachable code detected
            if (this.lowLevelManager == null)
#pragma warning restore CS0162 // Unreachable code detected
            {
                this.lowLevelManager = new LowLevelKeyboardHookManager();
            }

            if (this.appCommandManager == null)
            {
                this.appCommandManager = new AppCommandKeyboardHookManager(hWnd);
            }

            this.lowLevelManager.MediaKeyPlayPressed       += MediaKeyPlayPressedHandler;
            this.lowLevelManager.MediaKeyPreviousPressed   += MediaKeyPreviousPressedHandler;
            this.lowLevelManager.MediaKeyNextPressed       += MediaKeyNextPressedHandler;
            this.appCommandManager.MediaKeyPlayPressed     += MediaKeyPlayPressedHandler;
            this.appCommandManager.MediaKeyPreviousPressed += MediaKeyPreviousPressedHandler;
            this.appCommandManager.MediaKeyNextPressed     += MediaKeyNextPressedHandler;

            this.lowLevelManager.SetHook();
            this.appCommandManager.SetHook();
        }
Esempio n. 2
0
        public void Load()
        {
            Logger.Debug("Loading DebugHelper input hooks");

            process = new Process {
                StartInfo = new ProcessStartInfo(Path.Combine(Path.GetDirectoryName(typeof(DebugHelperMouseHookManager).Assembly.Location), "Blish HUD.DebugHelper.exe"), Process.GetCurrentProcess().Id.ToString())
                {
                    RedirectStandardInput  = true,
                    RedirectStandardOutput = true,
                    UseShellExecute        = false,
                    CreateNoWindow         = true
                }
            };

            Logger.Debug($"Starting external process: {process.StartInfo.FileName}");
            process.Start();

            debugHelperMessageService = new StreamMessageService(process.StandardOutput.BaseStream, process.StandardInput.BaseStream);
            debugHelperMessageService.Start();

            pingTimer = new Timer(10)
            {
                AutoReset = true
            };
            pingTimer.Elapsed += (s, e) => debugHelperMessageService.Send(new PingMessage());
            pingTimer.Start();

            mouseHookManager    = new DebugHelperMouseHookManager(debugHelperMessageService);
            keyboardHookManager = new DebugHelperKeyboardHookManager(debugHelperMessageService);
        }
Esempio n. 3
0
 public WinApiHookManager()
 {
     mouseHookManager    = new WinApiMouseHookManager();
     keyboardHookManager = new WinApiKeyboardHookManager();
 }