我正在尝试使用鼠标事件标志实现鼠标拖动功能。我需要以下内容:
我编写了以下代码,但这并没有完成任务。也许我错过了什么?
private void button4_Click(object sender, EventArgs e)
{
SetCursorPos(900, 250);
Point p1 = GetCursorPosition();
mouse_event((int)(MouseEventFlags.LEFTDOWN), 0, 0, 0, 0);
/* for (int i = 0; i < 50; i++)
{
System.Threading.Thread.Sleep(100);
SetCursorPos(720, 310+i*10);
this.Text = GetCursorPosition().ToString();
}*/
SetCursorPos(900, 450);
Point p2 = GetCursorPosition();
mouse_event((int)(MouseEventFlags.LEFTUP), 0, 0, 0, 0);
// mouse_event((int)(MouseEventFlags.MOVE), 720, 340, 0, 0);
}