1
如果我想控制鼠标光标,包括点击等,我需要使用什么API?例如,我正在使用Kinect为PC开发一个应用程序,并且我希望用这个来控制鼠标光标,而不是创建我自己的应用程序内光标。为了实现这个目标,我需要“挖掘”什么?C#/ Kinect控制鼠标光标
谢谢。马科斯Placona在
如果我想控制鼠标光标,包括点击等,我需要使用什么API?例如,我正在使用Kinect为PC开发一个应用程序,并且我希望用这个来控制鼠标光标,而不是创建我自己的应用程序内光标。为了实现这个目标,我需要“挖掘”什么?C#/ Kinect控制鼠标光标
谢谢。马科斯Placona在
见回答:How to simulate Mouse Click in C#?
现在你只需要添加鼠标移动事件。这里更多的信息:的http://pinvoke.net/default.aspx/user32.mouse_event
using System;
using System.Windows.Forms;
using System.Runtime.InteropServices;
public class Form1 : Form
{
[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 Form1()
{
}
public void DoMouseClick()
{
//Call the imported function with the cursor's current position
int X = Cursor.Position.X;
int Y = Cursor.Position.Y;
mouse_event(MOUSEEVENTF_LEFTDOWN | MOUSEEVENTF_LEFTUP, X, Y, 0, 0);
}
//...other code needed for the application
}
谢谢。将看看这些链接。 –
可能重复[?如何模拟鼠标点击在C#(http://stackoverflow.com/questions/2416748/how-to-simulate-mouse-click-in-c ) – RvdK
请参阅http://stackoverflow.com/questions/1503238/whats-the-difference-between-using-cursor-position-setcursorpos-sendinput。 –