int hitDaEnterKey()
{
INPUT ip;
// Set up a generic keyboard event.
ip.type = INPUT_KEYBOARD;
ip.ki.wScan = 0; // hardware scan code for key
ip.ki.time = 0;
ip.ki.dwExtraInfo = 0;
// Press and release Enter Key
ip.ki.wVk = 0x0D;
ip.ki.dwFlags = 0;
SendInput(1, &ip, sizeof(INPUT));
// release
ip.ki.dwFlags = KEYEVENTF_KEYUP;
SendInput(1, &ip, sizeof(INPUT));
return 0;
}
OR
int hitDaEnterKey(INPUT *ip)
{
// Press and release Enter Key
ip->ki.wVk = 0x0D;
ip->ki.dwFlags = 0;
SendInput(1, ip, sizeof(INPUT));
// release
ip->ki.dwFlags = KEYEVENTF_KEYUP;
SendInput(1, ip, sizeof(INPUT));
return 0;
}
int main()
{
// This structure will be used to create the keyboard
// input event.
INPUT ip;
Sleep(2500);
// Set up a generic keyboard event.
ip.type = INPUT_KEYBOARD;
ip.ki.wScan = 0; // hardware scan code for key
ip.ki.time = 0;
ip.ki.dwExtraInfo = 0;
// Press the "A" key
ip.ki.wVk = 0x41; // virtual-key code for the "a" key
ip.ki.dwFlags = 0; // 0 for key press
SendInput(1, &ip, sizeof(INPUT));
// Release the "A" key
ip.ki.dwFlags = KEYEVENTF_KEYUP; // KEYEVENTF_KEYUP for key release
SendInput(1, &ip, sizeof(INPUT));
hitDaEnterKey(&ip);
return 0;
}
solved Why iisn’t my function working when it’s called? [closed]