InputSimulator不会模拟鼠标点击

Tim*_*ler 3 c# mouse input click winforms

我正在使用InputSimulator来模拟按键和鼠标点击.到目前为止,我测试的每个键都有效,除了鼠标按钮.我发这样的话:

private void button2_Click(object sender, EventArgs e) //In this example I am trying to simulate the left mouse button
    {
        System.Threading.Thread.Sleep(2000); 
        InputSimulator.SimulateKeyPress(VirtualKeyCode.LBUTTON);
    }
Run Code Online (Sandbox Code Playgroud)

但没有任何反应.我做错了吗?

库:InputSimulator

yal*_*lie 5

最新版本的InputSimulator支持鼠标事件.以下是如何使用它:

var sim = new InputSimulator();
sim.Mouse.LeftButtonClick();
Run Code Online (Sandbox Code Playgroud)

请注意,二进制下载已过时,因此您必须从源代码构建库.