C# 模拟鼠标单击事件 FindWindow实例

        [DllImport("User32.dll", EntryPoint = "FindWindow")]

        private static extern IntPtr FindWindow(string lpClassName, string lpWindowName);



        private void button2_Click(object sender, EventArgs e)

        {

            IntPtr formHandle = FindWindow(null, "窗口标题");//0x0175015f十六进制坐标,十进制转十六进制(x高位,y低位)(0175)x=373,(015F)y=351

            SendMessage(formHandle, 0x0201, 0, (int)0x0175015f); //发送WM_LBUTTONDOWN=0x0201 左键按下

            SendMessage(formHandle, 0x0202, 0, (int)0x0175015f); //发送WM_LBUTTONUP=0x0202  左键抬起   

        }

你可能感兴趣的:(window)