以编程方式模拟鼠标向下/向上

时间:2016-04-02 04:57:15

标签: c#

我试图让我的mousedownup使用代码进行远程桌面交易。我设法用这个单击和双击:

    [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;

    uint ClickX = Convert.ToUInt32(Cursor.Position.X);
    uint ClickY = Convert.ToUInt32(Cursor.Position.Y);
    mouse_event(MOUSEEVENTF_LEFTDOWN | MOUSEEVENTF_LEFTUP, ClickX, ClickY, 0, 0);

然后双击只需2次点击。我发现了this MSDN,但这看起来像是唯一的moused,但这只是点击而不是保持我很确定。

0 个答案:

没有答案