当前位置:编程学习 > C#/ASP.NET >>

C#按住QQ的滚动条向下移动,应该怎么实现?

C#按住QQ的滚动条向下移动,应该怎么实现? --------------------编程问答-------------------- 我要是听懂你在说什么  我都是那个... --------------------编程问答-------------------- 楼主是不是在做外挂啊?如果是那样的话,那就是api模式鼠标点击。 --------------------编程问答--------------------
引用 2 楼 u011303459 的回复:
楼主是不是在做外挂啊?如果是那样的话,那就是api模式鼠标点击。


是的,但是,怎么按住推动鼠标呢 --------------------编程问答-------------------- 围观楼主做外挂 --------------------编程问答-------------------- 主要目的是按住滚动条向下拉20像素, --------------------编程问答-------------------- 一种方法是使用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)); --------------------编程问答-------------------- 另一种方法是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));
} --------------------编程问答-------------------- 楼上很强大! --------------------编程问答-------------------- 你居然能获取到 QQ 的句柄 牛牪犇
补充:.NET技术 ,  C#
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,