I have a C++ program that simulates a single key down key up every several minutes. The program is basically a console application and I run the program and it will press the given key to wherever the current focus is, not necessarily inside the application itself.
I do this by using SendInput
.
The same program doesn't work when I RDP to a computer and run the program directly on the remote host. My search for an answer led me to concepts like scan codes and mapping keys, but I'm not entirely sure if these are specific to my issue.
My original code is below. How can I edit this to make it work when launching the program in an RDP session?
INPUT inputs[2] = {};
ZeroMemory(inputs, sizeof(inputs));
inputs[0].type = INPUT_KEYBOARD;
inputs[0].ki.wVk = VK_F22;
inputs[1].type = INPUT_KEYBOARD;
inputs[1].ki.wVk = VK_F22;
inputs[1].ki.dwFlags = KEYEVENTF_KEYUP;
UINT uSent = SendInput(ARRAYSIZE(inputs), inputs, sizeof(INPUT));