Ok I found out how to use the scancodes to make the virtual keypress
// PRESS F8
ip.type = INPUT_KEYBOARD;
ip.ki.wScan = MapVirtualKey(VK_F8, 0); // hardware scan code for key
ip.ki.time = 0;
ip.ki.dwExtraInfo = 0;
ip.ki.wVk = 0;//0x77; // virtual-key code
ip.ki.dwFlags = KEYEVENTF_SCANCODE; // 0 for key press
SendInput(1, &ip, sizeof(INPUT));
if (GetKeyState( VK_F8) < 0) { std::cout << "press f8 \n";}
ip.ki.dwFlags = KEYEVENTF_SCANCODE | KEYEVENTF_KEYUP; // KEYEVENTF_KEYUP for key release
SendInput(1, &ip, sizeof(INPUT));
The dwFlags should be KEYEVENTF_SCANCODE else it will automatically use the VK code to determine which is supposed to be pressed.
Now it still does not send the virtual key press to the game I'm running. Whenever I'm in this game it just doesn't work, how can I fix this??