1
我無法理解下面的代碼。我不能對此做出很好的解釋。 我在我有疑問的代碼段旁邊留下了評論。C++鼠標點擊模擬代碼
void LeftClick ()
{
INPUT input = {0};
// left down
input.type = INPUT_MOUSE;
input.mi.dwFlags = MOUSEEVENTF_LEFTDOWN;
::SendInput(1,&input,sizeof(INPUT));
// left up
::ZeroMemory(&input,sizeof(INPUT)); // why zeroMemory? removing this code changes nothing that i can tell
input.type = INPUT_MOUSE; // why reset this variable? is it not already set?
input.mi.dwFlags = MOUSEEVENTF_LEFTUP;
::SendInput(1,&input,sizeof(INPUT));
}
您的兩個猜測一起會產生更好的代碼imo。 – chris