winform模拟鼠标点击

        //绑定事件 导入dll
        [System.Runtime.InteropServices.DllImport("user32")]
        private static extern int mouse_event(int mouseevent, int dx, int dy, int cButtons, int dwExtraInfo);
        [DllImport("User32")]
        public extern static void SetCursorPos(int x, int y);  


        private void button2_Click(object sender, EventArgs e)
        {
            //移动鼠标 
            const int MOUSEEVENTF_MOVE = 0x0001;
            //模拟鼠标左键按下 
            const int MOUSEEVENTF_LEFTDOWN = 0x0002;
            //模拟鼠标左键抬起 
            const int MOUSEEVENTF_LEFTUP = 0x0004;
            //模拟鼠标右键按下 
            const int MOUSEEVENTF_RIGHTDOWN = 0x0008;
            //模拟鼠标右键抬起 
            const int MOUSEEVENTF_RIGHTUP = 0x0010;
            //模拟鼠标中键按下 
            const int MOUSEEVENTF_MIDDLEDOWN = 0x0020;
            //模拟鼠标中键抬起 
            const int MOUSEEVENTF_MIDDLEUP = 0x0040;
            //标示是否采用绝对坐标 
            const int MOUSEEVENTF_ABSOLUTE = 0x8000;

            SetCursorPos(40, 65);  //设置鼠标放的位置

            //连续两次点击--
            mouse_event(MOUSEEVENTF_LEFTDOWN | MOUSEEVENTF_LEFTUP, 0, 0, 0, 0);
            mouse_event(MOUSEEVENTF_LEFTDOWN | MOUSEEVENTF_LEFTUP, 0, 0, 0, 0);
        } 

 

Giser_D CSDN认证博客专家 C/C++
https://github.com/huifeng-kooboo编程爱好者,喜欢学习客户端技术和网站后端技术、对爬虫技术颇有研究
已标记关键词 清除标记
©️2020 CSDN 皮肤主题: 点我我会动 设计师:白松林 返回首页