void MouseButtonDown()
{
INPUT Input={0};
Input.type = INPUT_MOUSE;
Input.mi.dwFlags = MOUSEEVENTF_LEFTDOWN;
::SendInput(1,&Input,sizeof(INPUT));
}
void MouseButtonUp()
{
INPUT Input={0};
Input.type = INPUT_MOUSE;
Input.mi.dwFlags = MOUSEEVENTF_LEFTUP;
::SendInput(1,&Input,sizeof(INPUT));
}
void RightClickDown()
{
INPUT Input={0};
// 右键按下
Input.type = INPUT_MOUSE;
Input.mi.dwFlags = MOUSEEVENTF_RIGHTDOWN;
::SendInput(1,&Input,sizeof(INPUT));
}
void RightClickUp()
{
INPUT Input={0};
Input.type = INPUT_MOUSE;
Input.mi.dwFlags = MOUSEEVENTF_RIGHTUP;
::SendInput(1,&Input,sizeof(INPUT));
}
这部分是鼠标模拟的代码,通过函数实现鼠标左右键的点击。
然后通过判断左右手的动作去掉用这些函数,进而实现姿势模拟点击。
if (PointList.size()==4)
{
if (PointList.front().Z-PointList.back().Z>100&&PointList.front().X-PointList.back().X<100&&PointList.front().Z-PointList.back().Z<200)
{
MouseButtonDown();
MouseButtonUp();
}
else if (PointList.front().Z-PointList.back().Z<100&&PointList.front().X-PointList.back().X>100)
{
RightClickDown();
RightClickUp();
}
if (MainPointList.front().Z-MainPointList.back().Z>100&&MainPointList.front().Z-MainPointList.back().Z<200)
{
MouseButtonDown();
}
else if (MainPointList.front().Z-MainPointList.back().Z<-50)
{
MouseButtonUp();
iswhell=FALSE;
}