コード例 #1
0
        /// <summary>
        /// This method sets the mouse and/or the keyboard hook into place and starts listening for input events.
        /// </summary>
        public void Listen()
        {
            var thread = new Thread(() =>
            {
                _keyboardHook?.SetHook();
                _mouseHook?.SetHook();

                ThreadContext.MessageLoop();
            });

            thread.IsBackground = true;
            thread.SetApartmentState(ApartmentState.STA);
            thread.Start();
        }