The file is Virtual-Key Codes . This is stored in JSON. I use rapidjson to deserialize JSON.
The project has a function:

void PressButton(list<WORD> wVkArray) { INPUT ip; ip.type = INPUT_KEYBOARD; ip.ki.wScan = 0; ip.ki.time = 0; ip.ki.dwExtraInfo = 0; for (auto &wVk : wVkArray) { ip.ki.wVk = wVk; ip.ki.dwFlags = 0; SendInput(1, &ip, sizeof(INPUT)); } for (auto &wVk : wVkArray) { ip.ki.wVk = wVk; ip.ki.dwFlags = KEYEVENTF_KEYUP; SendInput(1, &ip, sizeof(INPUT)); } } 

In the project, the resulting Virtual-Key Codes are stored in a String.

Question: how to string String in WORD to pass Virtual-Key Codes to function parameters?

    1 answer 1

    WORD is unsigned short. So I needed to convert the String to an unsigned short.

     unsigned short StringToShort(std::string str) { unsigned short x; std::stringstream ss; ss << std::hex << str; ss >> x; return x; }