0

我正在开发一个程序,我想将我的关节在 kinect 中的位置设置为鼠标光标。我不知道与鼠标一起使用的 api 及其功能以及我必须添加的命名空间。例如一些设置鼠标指针位置的功能和一些右键单击和左键单击和双击的功能。例如,我想要“如果我的手关节在我的左关节鼠标上方,我可以使用 kinect sdk,但我不知道有关它的 win api。
感谢您的帮助。

4

1 回答 1

1

对于职位:

[DllImport("user32")]
public static extern int SetCursorPos(int x, int y);

对于鼠标单击:

[DllImport("user32")]
public static extern void mouse_event(int dwFlags, int dx, int dy, int cButtons, int dwExtraInfo);

public const int MOUSEEVENTF_LEFTDOWN = 0x02;
public const int MOUSEEVENTF_LEFTUP = 0x04;
public const int MOUSEEVENTF_RIGHTDOWN = 0x08;
public const int MOUSEEVENTF_RIGHTUP = 0x10;

public void MouseClick(int x, int y)
{
    mouse_event(MOUSEEVENTF_LEFTDOWN, x, y, 0, 0);
    mouse_event(MOUSEEVENTF_LEFTUP, x, y, 0, 0);
}

我认为代码非常清晰和简单,玩得开心^^

于 2013-08-10T20:54:49.877 回答