楼主是不是在做外挂啊?如果是那样的话,那就是api模式鼠标点击。

解决方案 »

  1.   

    一种方法是使用mouse_event函数,这种方法鼠标会真的移动,需要提供相对于屏幕的坐标        [DllImport("user32.dll", EntryPoint = "SetCursorPos")]
            public static extern int SetCursorPos(int x, int y);        [DllImport("user32.dll", EntryPoint = "mouse_event")]
            public static extern void mouse_event(
                int dwFlags,
                int dx,
                int dy,
                int cButtons,
                int dwExtraInfo
            );        public const int MOUSEEVENTF_MOVE = 0x0001;      //移动鼠标 
            public const int MOUSEEVENTF_LEFTDOWN = 0x0002; //模拟鼠标左键按下 
            public const int MOUSEEVENTF_LEFTUP = 0x0004; //模拟鼠标左键抬起 
            public const int MOUSEEVENTF_RIGHTDOWN = 0x0008; //模拟鼠标右键按下 
            public const int MOUSEEVENTF_RIGHTUP = 0x0010; //模拟鼠标右键抬起 
            public const int MOUSEEVENTF_MIDDLEDOWN = 0x0020; //模拟鼠标中键按下 
            public const int MOUSEEVENTF_MIDDLEUP = 0x0040;// 模拟鼠标中键抬起 
            public const int MOUSEEVENTF_ABSOLUTE = 0x8000; //标示是否采用绝对坐标        /// <summary>
            /// 
            /// </summary>
            /// <param name="pSor">滚动条当前坐标</param>
            /// <param name="pDst">滚动条目标坐标</param>
            private static void MoveScroll(Point pSor,Point pDst)
            {
                mouse_event(Api.MOUSEEVENTF_LEFTDOWN, pSor.X, pSor.Y, 0, 0);
                mouse_event(Api.MOUSEEVENTF_MOVE, pDst.X - pSor.X, pDst.Y - pSor.Y, 0, 0);
                mouse_event(Api.MOUSEEVENTF_LEFTUP, pDst.X, pDst.Y, 0, 0);
            }调用方法:
    SetCursorPos(x,y);            
    MoveScroll(new Point(x, y), new Point(x, y + 20));
      

  2.   

    另一种方法是SendMessage,需要qq窗口的句柄和相对于qq的坐标        /// <summary>
            /// 发送信息
            /// </summary>
            /// <param name="hwnd"></param>
            /// <param name="wMsg"></param>
            /// <param name="wParam"></param>
            /// <param name="lParam"></param>
            /// <returns></returns>
            [DllImport("user32.dll", EntryPoint = "SendMessageA")]
            public static extern int SendMessage(IntPtr hwnd, int wMsg, IntPtr wParam, IntPtr lParam);        [DllImport("USER32.DLL")]
            public static extern IntPtr FindWindow(string lpClassName,
                string lpWindowName);        /// <summary>
            /// 
            /// </summary>
            /// <param name="ptr">窗体句柄</param>
            /// <param name="pSor">滚动条当前坐标</param>
            /// <param name="pDst">滚动条目标坐标</param>
            private static void MoveScroll2(IntPtr ptr, Point pSor, Point pDst)
            {
                //坐标信息
                IntPtr lParam = (IntPtr)((pSor.Y << 16) | pSor.X);
                IntPtr wParam = IntPtr.Zero;
                const int leftdownCode = 0x201;
                const int leftupCode = 0x202;
                //移动鼠标时发生,同WM_MOUSEFIRST   
                const int WM_MOUSEMOVE = 0x200;              SendMessage(ptr, leftdownCode, wParam, lParam);
                lParam = (IntPtr)((pDst.Y << 16) | pDst.X);
                SendMessage(ptr, WM_MOUSEMOVE, wParam, lParam);
                SendMessage(ptr, leftupCode, wParam, lParam);
            }调用方法:
    IntPtr ptrQQ = Api.FindWindow(null, "QQ2013");
    if (ptrQQ != IntPtr.Zero)
    {
    MoveScroll2(ptrQQ,new Point(x, y), new Point(x, y + MoveDown));
    }