所以我试图模拟鼠标左键单击和左鼠标释放做一些自动拖放。试图模拟鼠标点击/拖动
它目前在C#Winforms(是,winforms:|),并且有点像鹅。
基本上,一旦点击被发送,我希望它根据Kinect输入更新光标位置。 Kinect的一面是好的,但我不知道如何找到按钮是否仍然按下。
这里是我正在使用的代码+一些psuedocode来帮助更好地解释我自己(做的同时)。
class MouseImpersonator
{
[DllImport("user32.dll", CharSet = CharSet.Auto, CallingConvention = CallingConvention.StdCall)]
private static extern void mouse_event(uint dwFlags, uint dx, uint dy, uint cButtons, uint dwExtraInfo);
private const int leftDown = 0x02;
private const int leftUp = 0x04;
public static void Grab(int xPos, int yPos)
{
Cursor.Position = new Point(xPos + 25, yPos + 25);
mouse_event(leftDown, (uint) xPos, (uint) yPos, 0, 0);
//do
//{
//Cursor.Position = new Point(KinectSettings.movement.LeftHandX, KinectSettings.movement.LeftHandY);
//} while (the left mouse button is still clicked);
}
public static void Release(int xPos, int yPos)
{
Cursor.Position = new Point(xPos + 25, yPos + 25);
mouse_event(leftUp, (uint) xPos, (uint) yPos, 0, 0);
}
}
我已经有谷歌的追捕而无法找到我所需要的只是一个WPF相当于什么:http://msdn.microsoft.com/en-us/library/system.windows.input.mouse.aspx
我有点出我的深度,但任何帮助非常感谢。
卢卡斯。
-
-
对于名称空间是WPF的一部分的信息。当您输入发布版时,是否尝试将布尔变量设置为true时输入Grab和False? – 2011-12-19 13:10:45
偷偷摸摸的WPF,感谢Mark,已经调整了这个问题。我想过布尔方法,但认为可能会有更优雅的东西。如果我/任何人都不能想到另一种方法,它会工作,只是试图避免总是采取简单的方式:) – Lucas 2011-12-19 13:21:50
声明是错误的,最后一个参数是IntPtr。通过IntPtr.Zero。 – 2011-12-19 15:31:41