我正在使用如何在 C# 中模拟鼠标单击中的以下代码?我发现它不起作用。这是代码:
[DllImport("user32.dll", CharSet = CharSet.Auto, CallingConvention = CallingConvention.StdCall)]
public static extern void mouse_event(uint dwFlags, uint dx, uint dy, uint cButtons, uint dwExtraInfo);
private const int MOUSEEVENTF_LEFTDOWN = 0x02;
private const int MOUSEEVENTF_LEFTUP = 0x04;
private const int MOUSEEVENTF_RIGHTDOWN = 0x08;
private const int MOUSEEVENTF_RIGHTUP = 0x10;
public void DoMouseClick()
{
mouse_event(MOUSEEVENTF_LEFTDOWN | MOUSEEVENTF_LEFTUP, 882, 554, 0, 0);
}
private void button1_Click(object sender, EventArgs e)
{
DoMouseClick();
}
我也尝试过替换mouse_event(MOUSEEVENTF_LEFTDOWN | MOUSEEVENT_LEFTUP...
,mouse_event(MOUSEEVENTF_LEFTDOWN & MOUSEEVENT_LEFTUP...
但仍然没有运气。其他人已经成功了......为什么我没有?