模拟鼠标发送点击
本帖最后由 u010233208 于 2013-04-16 11:32:17 编辑
怎么样能模拟鼠标快速点击
PostMessage(ip, WM_LBUTTONDOWN, 1, lparam);
Thread.Sleep(100);
PostMessage(ip, WM_LBUTTONUP, 1, lparam);
PostMessage中间不加Thread的话 会失常 有没有更快点击的办法
鼠标
点击
------解决方案-------------------- [DllImport("User32.dll", EntryPoint = "SendMessage")]
private static extern int SendMessage(
IntPtr hWnd,
int Msg,
int wParam,
int lParam
);
private void button1_Click(object sender, EventArgs e)
{
SendMessage((IntPtr)comboBox2.Handle, 0x0201, 0, 0);
SendMessage((IntPtr)comboBox2.Handle, 0x0202, 0, 0);
}
其中API参数的含义为:
//按下鼠标左键
public static int WM_LBUTTONDOWN = 0x0201;
//释放鼠标左键
public static int WM_LBUTTONUP = 0x0202;
这个中间不用延时,因为SendMessage是等待消息返回再执行下一个,而PostMessage不等待消息返回就执行下一个