I am using the following standard GenerateKey Code :
void GenerateKey ( int vk , BOOL bExtended)
{
KEYBDINPUT kb={0};
INPUT Input={0};
// generate down
if ( bExtended )
kb.dwFlags = KEYEVENTF_EXTENDEDKEY;
kb.wVk = vk;
Input.type = INPUT_KEYBOARD;
Input.ki = kb;
::SendInput(1,&Input,sizeof(Input));
// generate up
::ZeroMemory(&kb,sizeof(KEYBDINPUT));
::ZeroMemory(&Input,sizeof(INPUT));
kb.dwFlags = KEYEVENTF_KEYUP;
if ( bExtended )
kb.dwFlags |= KEYEVENTF_EXTENDEDKEY;
kb.wVk = vk;
Input.type = INPUT_KEYBOARD;
Input.ki = kb;
::SendInput(1,&Input,sizeof(Input));
}
I call this function to simulate the arrow keys(up, down, left, right). However, this works in the normal explorer window and small flash games. However, when I try it on games like Need for Speed or Roadrash it does not work.. Any possible reasons for this behavior?