I'm working on a piece of C++ code. I am trying to simulate pressing ctrl and v for copy paste. The code does press ctrl and v but it doesn't release the ctrl key afterwards.
How would you improve the code to do ctrl v and release both keys?
Code
#include <Windows.h>
int main()
{
while(true) {
Sleep(3000);
INPUT Input = { 0 };
Input.type = INPUT_KEYBOARD;
// Control Key Down
Input.ki.wVk = 0x11; // Control Key
Input.ki.dwFlags = 0;
SendInput(1, &Input, sizeof(Input));
// V Key Down
Input.ki.wVk = 0x56; // V Key
Input.ki.dwFlags = 0;
SendInput(1, &Input, sizeof(Input));
// Keyboard UP
Input.ki.dwFlags = KEYEVENTF_KEYUP;
}
}