コード例 #1
0
        /// <summary>
        /// Thread message loop.
        /// To stop windows becoming unresponsive due to us not returning from the hook callback methods fast enough, we process
        /// inputs on a dedicated thread.
        /// </summary>
        private void ThreadLoop(CancellationToken token)
        {
            try
            {
                while (!token.IsCancellationRequested)
                {
                    Win32Msg msg = inputQueue.Take(token);

                    int cmd = (int)msg.wParam;

                    if (cmd == WM_KEYDOWN || cmd == WM_KEYUP || cmd == WM_SYSKEYDOWN || cmd == WM_SYSKEYUP)
                    {
                        IsThreadHandleKeyboard(msg.wParam, (KBDLLHOOKSTRUCT)msg.lParam);
                    }
                    else if (cmd >= 512 && cmd <= 524)
                    {
                        IsThreadHandleMouse(msg.wParam, (MSLLHOOKSTRUCT)msg.lParam);
                    }
                    else if (cmd == INPUTSHARE_CLIPBOARDTEXTCOPY)
                    {
                        ClipboardTextCopied?.Invoke(this, msg.cbText);
                    }
                    else
                    {
                        ISLogger.Write("Unhandled wparam code {0}", msg.wParam);
                    }
                }
            }
            catch (OperationCanceledException)
            {
            }

            ISLogger.Write("Input thread message queue exited");
        }
コード例 #2
0
 public static extern bool PostMessage(IntPtr hWnd, Win32Msg Msg, IntPtr wParam, IntPtr lParam);
コード例 #3
0
 public static extern IntPtr SendMessageW(IntPtr hwnd, Win32Msg Msg, IntPtr wParam, IntPtr lParam);
コード例 #4
0
 public static extern IntPtr SendMessageW(IntPtr hwnd, Win32Msg Msg, IntPtr wParam, IntPtr lParam);
コード例 #5
0
 public static extern bool PostMessage(IntPtr hWnd, Win32Msg Msg, IntPtr wParam, IntPtr lParam);