SendInput does not take in a string as parameter.
Sendinput(cInputs, pInputs, cbSize);
//cInputs = number of structures in the pInputs array..
//pInputs = a pointer to a INPUT structure which contains info about your mouse/key event.
//cbSize = the size of the structure. Tip! use sizeof();
//Step 1.
//Declare a KEYBDINPUT struct and set appropriate values to each variable.
//See MSDN...
//
//Step 2.
//Declare a INPUT structure.
//Set type: INPUT_KEYBOARD. then set "yourinputstruct".ki equal to your keybdinput struct
//
//Step 3:
//Use Sendinput function! Sendinput(1,&yourinputstruct, sizeof(yourinutstruct));
for list of Virtual Keycodes see MSDN.
https://learn.microsoft.com/en-us/windows/win32/inputdev/virtual-key-codes
Here is the function that I wrote, it still may need some improvements but I think it will do what you are asking for! at least it´s working for me typing in cmd and notepad... Read on msdn or ask me to comment if it is hard to understand!
Just pass in a Virtual keycode as first parameter and true if it is a extended key and false if it´s not!
void KeyPress(unsigned short VK, bool ExtendedKey)
{
KEYBDINPUT KeyDown = { 0 };
KEYBDINPUT KeyUp = { 0 };
INPUT Input[2] = { 0 };
//KeyDown...
KeyDown.wVk = VK;
KeyDown.wScan = 0;
KeyDown.time = 10;
KeyDown.dwFlags = 0;
KeyDown.dwExtraInfo = 0;
if (ExtendedKey == true)
{
KeyDown.wVk = VK;
KeyDown.wScan = 0;
KeyDown.time = 1000;
KeyDown.dwFlags = KEYEVENTF_EXTENDEDKEY;
KeyDown.dwExtraInfo = 0;
}
//KeyUp...
KeyUp.wVk = VK;
KeyUp.wScan = 0;
KeyUp.time = 10;
KeyUp.dwFlags = KEYEVENTF_KEYUP;
KeyUp.dwExtraInfo = 0;
if (ExtendedKey == true)
{
KeyUp.wVk = VK;
KeyUp.wScan = 0;
KeyUp.time = 10;
KeyUp.dwFlags = KEYEVENTF_EXTENDEDKEY | KEYEVENTF_KEYUP;
KeyUp.dwExtraInfo = 0;
}
//Setup Input...
Input[0].type = INPUT_KEYBOARD;
Input[0].ki = KeyDown;
Input[1].type = INPUT_KEYBOARD;
Input[1].ki = KeyUp;
//Click and Release!
SendInput(1, &Input[0], sizeof(Input[0]));
SendInput(1, &Input[1], sizeof(Input[1]));
}