MouseKeyboardActivityMonitor/MouseHookListener.cs

(开头部分) 9KB

这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。

using System;
using System.Windows.Forms;
using MouseKeyboardActivityMonitor.WinApi;

namespace MouseKeyboardActivityMonitor
{
	/// <summary>
	/// This class monitors all mouse activities and provides appropriate events.
	/// </summary>
	public class MouseHookListener : BaseHookListener
	{

		private Point m_PreviousPosition;
        private int m_PreviousClickedTime;
        private Point m_PreviousClickedPosition;
		private MouseButtons m_PreviousClicked;
		private MouseButtons m_DownButtonsWaitingForMouseUp;
		private MouseButtons m_SuppressButtonUpFlags;
        private int m_SystemDoubleClickTime;

		/// <summary>
		/// Initializes a new instance of <see cref="MouseHookListener"/>.
		/// </summary>
		/// <param name="hooker">Depending on this parameter the listener hooks either application or global mouse events.</param>
		/// <remarks>
        /// Hooks are not active after installation. You need to use either <see cref="BaseHookListener.Enabled"/> property or call <see cref="BaseHookListener.Start"/> method.
        /// </remarks>
		public MouseHookListener(Hooker hooker)
			: base(hooker)
		{
			m_PreviousPosition = new Point(-1, -1);
            m_PreviousClickedTime = 0;
			m_DownButtonsWaitingForMouseUp = MouseButtons.None;
            m_SuppressButtonUpFlags = MouseButtons.None;
			m_PreviousClicked = MouseButtons.None;
            m_SystemDoubleClickTime = MouseNativeMethods.GetDoubleClickTime();
		}

        //##################################################################
        #region ProcessCallback and related subroutines

        /// <summary>
        /// This method processes the data from the hook and initiates event firing.
        /// </summary>
        /// <param name="wParam">The first Windows Messages parameter.</param>
        /// <param name="lParam">The second Windows Messages parameter.</param>
        /// <returns>
        /// True - The hook will be passed along to other applications.
        /// <para>
        /// False - The hook will not be given to other applications, effectively blocking input.
        /// </para>
        /// </returns>
        protected override bool ProcessCallback(int wParam, IntPtr lParam)
        {
            MouseEventExtArgs e = MouseEventExtArgs.FromRawData(wParam, lParam, IsGlobal);

            if (e.IsMouseKeyDown)
            {
                ProcessMouseDown(ref e);
            }
后面还有 240 行代码,解锁后查看完整代码

24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明

AI 解读 AI

登录后可用,每次 10 算力,解读结果公开显示在下面。

还没有人解读过这个文件。