I'm making a small program to select the keyword where I've placed the caret on. I'm trying to send Shift + Ctrl + Right Arrow from my program to any active window to select the text.
The problem is the "Shift" key is not sent and the text is not selected.
How can I do it?
This is my code that I have tried:
// Generate Ctrl + Shift + RightArrow input
INPUT copyText[6];
// Set the press of the "Shift" key
copyText[0].ki.wVk = VK_SHIFT;
copyText[0].ki.dwFlags = 0; // 0 for key press
copyText[0].type = INPUT_KEYBOARD;
// Set the press of the "Ctrl" key
copyText[1].ki.wVk = VK_CONTROL;
copyText[1].ki.dwFlags = 0; // 0 for key press
copyText[1].type = INPUT_KEYBOARD;
// Set the press of the "C" key
copyText[2].ki.wVk = VK_RIGHT;
copyText[2].ki.dwFlags = 0;
copyText[2].type = INPUT_KEYBOARD;
// Set the Release of the "Shift" key
copyText[3].ki.wVk = VK_SHIFT;
copyText[3].ki.dwFlags = KEYEVENTF_KEYUP;
copyText[3].type = INPUT_KEYBOARD;
// Set the Release of the "Ctrl" key
copyText[4].ki.wVk = VK_CONTROL;
copyText[4].ki.dwFlags = KEYEVENTF_KEYUP;
copyText[4].type = INPUT_KEYBOARD;
// Set the Release of the "C" key
copyText[5].ki.wVk = VK_RIGHT;
copyText[5].ki.dwFlags = KEYEVENTF_KEYUP;
copyText[5].type = INPUT_KEYBOARD;
// Send key sequence to system
SendInput(static_cast<UINT>(std::size(copyText)), copyText, sizeof(INPUT));