Im having trouble understanding the code bellow. and i cant fined a good explanation of it. I left comments next to the code segments i have questions for.
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));
}
i got this code at http://forums.codeguru.com/showthread.php?377394-Windows-SDK-User-Interface-How-can-I-emulate-mouse-events-in-an-application