所以我试图模拟鼠标左键单击和左键鼠标释放来进行一些自动拖放操作.
它目前处于C#Winforms(是的,winforms:|)并且有点像鹅.
基本上,一旦发送了Click,我希望它根据Kinect输入更新光标位置. Kinect方面的情况很好,但我不知道如何找到按钮是否仍然按下.
这里的代码我正在使用一些伪代码来帮助更好地解释自己(do while).
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); //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,yPos + 25); mouse_event(leftUp,0); } }
我有一个谷歌的搜索,除了相当于WPF之外,找不到我需要的东西:http://msdn.microsoft.com/en-us/library/system.windows.input.mouse.aspx
我有点超出我的深度,但任何帮助都非常感谢.
卢卡斯.
–
解决方法
最简单的答案实际上是使用bool并只是检查一下发生了什么.
我在一个新线程上启动它,所以它没有打破其他一切.
希望你能整理一下这个.
public static void Grab(int xPos,int yPos) { _dragging = true; Cursor.Position = new Point(xPos,yPos + offSet); mouse_event(leftDown,0); var t = new Thread(CheckMouseStatus); t.Start(); } public static void Release(int xPos,int yPos) { _dragging = false; Cursor.Position = new Point(xPos,yPos + offSet); mouse_event(leftUp,0); } private static void CheckMouseStatus() { do { Cursor.Position = new Point(KinectSettings.movement.HandX,KinectSettings.movement.HandY + offSet); } while (_dragging); }
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。