c# - InputSimulator 不模拟鼠标点击

标签 c# winforms input click mouse

我正在使用 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);
    }

但是没有任何反应。我做错了什么吗?

图书馆:InputSimulator

最佳答案

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

var sim = new InputSimulator();
sim.Mouse.LeftButtonClick();

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

关于c# - InputSimulator 不模拟鼠标点击,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18920235/

相关文章:

c# - TreeNode 鼠标悬停工具提示未显示

.net - 当我调整标签的大小时,代码垃圾会在新的空白区域短暂显示

c - 动态 fscanf 到数组中

javascript - 使用 jquery 以表单形式克隆文件上传输入字段

c# - Left Join Mysql 查询结果错误

c# - 如何从搜索引擎获取使用的关键字

c# - HTTPClient 每次返回相同的字符串

c# - 在 C# 中查找有关通过 USB 连接的所有串行设备的信息

c# - 如何访问 UserControl 上的控件?

Javascript:点击按钮后输入