I Want To Send These Keys To Active Window To Copy The Text which i stand on it
Keys : Shift + Right Arrow
Then : Ctrl + Left Arrow
Then : Shift + Ctrl + Right Arrow
Then : Ctrl + C
// I Tried This Code But Shift Key not Released so, Copy Operation have not Done
// i wrote This Code also in one array in sent as one but same problem
// Wait until all modifiers will be unpressed (to avoid conflicts with the other shortcuts)
while (GetAsyncKeyState(VK_LWIN) || GetAsyncKeyState(VK_RWIN) || GetAsyncKeyState(VK_SHIFT) || GetAsyncKeyState(VK_MENU) || GetAsyncKeyState(VK_CONTROL)) {};
//// Generate Ctrl + C input
INPUT copyText[1];
ZeroMemory(©Text, sizeof(copyText));
// Set the press of the "Right" key
copyText[0].ki.wVk = VK_RIGHT;
copyText[0].ki.dwFlags = 0; // 0 for key press
copyText[0].type = INPUT_KEYBOARD;
SendInput(static_cast<UINT>(std::size(copyText)), copyText, sizeof(INPUT));
ZeroMemory(©Text, sizeof(copyText));
// Set the Release of the "Right" key
copyText[0].ki.wVk = VK_RIGHT;
copyText[0].ki.dwFlags = KEYEVENTF_KEYUP; // 0 for key press
copyText[0].type = INPUT_KEYBOARD;
SendInput(static_cast<UINT>(std::size(copyText)), copyText, sizeof(INPUT));
ZeroMemory(©Text, sizeof(copyText));
// Set the press of the "Ctrl" key
copyText[0].ki.wVk = VK_CONTROL;
copyText[0].ki.dwFlags = 0; // 0 for key press
copyText[0].type = INPUT_KEYBOARD;
SendInput(static_cast<UINT>(std::size(copyText)), copyText, sizeof(INPUT));
ZeroMemory(©Text, sizeof(copyText));
// Set the press of the "Left" key
copyText[0].ki.wVk = VK_LEFT;
copyText[0].ki.dwFlags = 0; // 0 for key press
copyText[0].type = INPUT_KEYBOARD;
SendInput(static_cast<UINT>(std::size(copyText)), copyText, sizeof(INPUT));
ZeroMemory(©Text, sizeof(copyText));
// Set the Release of the "Left" key
copyText[0].ki.wVk = VK_LEFT;
copyText[0].ki.dwFlags = KEYEVENTF_KEYUP; // 0 for key press
copyText[0].type = INPUT_KEYBOARD;
SendInput(static_cast<UINT>(std::size(copyText)), copyText, sizeof(INPUT));
ZeroMemory(©Text, sizeof(copyText));
// Set the Release of the "Ctrl" key
copyText[0].ki.wVk = VK_CONTROL;
copyText[0].ki.dwFlags = KEYEVENTF_KEYUP; // 0 for key press
copyText[0].type = INPUT_KEYBOARD;
SendInput(static_cast<UINT>(std::size(copyText)), copyText, sizeof(INPUT));
ZeroMemory(©Text, sizeof(copyText));
// Set the press of the "Ctrl" key
copyText[0].ki.wVk = VK_CONTROL;
copyText[0].ki.dwFlags = 0; // 0 for key press
copyText[0].type = INPUT_KEYBOARD;
SendInput(static_cast<UINT>(std::size(copyText)), copyText, sizeof(INPUT));
ZeroMemory(©Text, sizeof(copyText));
//// Set the press of the "Shift" key
copyText[0].ki.wVk = VK_SHIFT;
copyText[0].ki.dwFlags = KEYEVENTF_EXTENDEDKEY | 0;
copyText[0].type = INPUT_KEYBOARD; // Type Of Input
SendInput(static_cast<UINT>(std::size(copyText)), copyText, sizeof(INPUT));
ZeroMemory(©Text, sizeof(copyText));
// Set the press of the "Right" key
copyText[0].ki.wVk = VK_RIGHT;
copyText[0].ki.dwFlags = 0; // 0 for key press
copyText[0].type = INPUT_KEYBOARD;
SendInput(static_cast<UINT>(std::size(copyText)), copyText, sizeof(INPUT));
ZeroMemory(©Text, sizeof(copyText));
// Set the Release of the "Right" key
copyText[0].ki.wVk = VK_RIGHT;
copyText[0].ki.dwFlags = KEYEVENTF_KEYUP; // 0 for key press
copyText[0].type = INPUT_KEYBOARD;
SendInput(static_cast<UINT>(std::size(copyText)), copyText, sizeof(INPUT));
ZeroMemory(©Text, sizeof(copyText));
////// Set of Release the "Shift" Key
copyText[0].ki.wVk = VK_SHIFT;
copyText[0].ki.dwFlags = KEYEVENTF_EXTENDEDKEY | KEYEVENTF_KEYUP; // 0 for key press
copyText[0].type = INPUT_KEYBOARD;
SendInput(static_cast<UINT>(std::size(copyText)), copyText, sizeof(INPUT));
ZeroMemory(©Text, sizeof(copyText));
// Set the press of the "Ctrl" key
copyText[0].ki.wVk = VK_CONTROL;
copyText[0].ki.dwFlags = KEYEVENTF_KEYUP; // 0 for key press
copyText[0].type = INPUT_KEYBOARD;
SendInput(static_cast<UINT>(std::size(copyText)), copyText, sizeof(INPUT));
ZeroMemory(©Text, sizeof(copyText));
// Set the press of the "Ctrl" key
copyText[0].ki.wVk = VK_CONTROL;
copyText[0].ki.dwFlags = 0; // 0 for key press
copyText[0].type = INPUT_KEYBOARD;
SendInput(static_cast<UINT>(std::size(copyText)), copyText, sizeof(INPUT));
ZeroMemory(©Text, sizeof(copyText));
// Set the press of the "C" key
copyText[0].ki.wVk = 'C';
copyText[0].ki.dwFlags = 0; // 0 for key press
copyText[0].type = INPUT_KEYBOARD;
SendInput(static_cast<UINT>(std::size(copyText)), copyText, sizeof(INPUT));
ZeroMemory(©Text, sizeof(copyText));
// Set the Release of the "C" key
copyText[0].ki.wVk = 'C';
copyText[0].ki.dwFlags = KEYEVENTF_KEYUP; // 0 for key press
copyText[0].type = INPUT_KEYBOARD;
SendInput(static_cast<UINT>(std::size(copyText)), copyText, sizeof(INPUT));
ZeroMemory(©Text, sizeof(copyText));
// Set the Release of the "Ctrl" key
copyText[0].ki.wVk = VK_CONTROL;
copyText[0].ki.dwFlags = KEYEVENTF_KEYUP; // 0 for key press
copyText[0].type = INPUT_KEYBOARD;
SendInput(static_cast<UINT>(std::size(copyText)), copyText, sizeof(INPUT));