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。 –