I am trying to print the corresponding Unicode character for alt+2 to the Windows console window. (the console doesn't display the character, but should display ^B instead)
The following doesn't seem to work. Just prints "2".
keybd_event(VK_MENU,0 ,0 , 0); //Alt Press
Sleep(10);
keybd_event(VK_NUMPAD2,0, 0 , 0); // 2 Press
Sleep(10);
keybd_event(VK_NUMPAD2,0, KEYEVENTF_KEYUP,0); // 2 Release
Sleep(10);
keybd_event(VK_MENU,0,KEYEVENTF_KEYUP,0); // Alt Release
Sleep(10);
Neither does this work. Again, just prints "2".
INPUT inputs = {0};
inputs.type = INPUT_KEYBOARD;
KEYBDINPUT ki = {0};
ki.wVk = VK_LMENU;
inputs.ki = ki;
SendInput(1, &inputs, sizeof(INPUT)); // Left alt
ki.wVk = VK_NUMPAD2;
inputs.ki = ki;
SendInput(1, &inputs, sizeof(INPUT)); // Numpad 2
ki.dwFlags = KEYEVENTF_KEYUP;
ki.wVk = VK_NUMPAD2;
inputs.ki = ki;
SendInput(1, &inputs, sizeof(INPUT)); // Numpad 2
ki.wVk = VK_LMENU;
inputs.ki = ki;
SendInput(1, &inputs, sizeof(INPUT)); // Left alt