Wednesday, 13 July 2011

VK_ALT undeclared / undefined C++

It's actually defined as VK_MENU

e.g.


// VK_ALT
void AltKey()
{
    INPUT input[1] = { '\0' };       
 memset(input, 0, sizeof(input));          
 input[0].type = INPUT_KEYBOARD;   
 input[0].ki.dwFlags = 0; // KEYEVENTF_EXTENDEDKEY; 
 input[0].ki.wVk = VK_MENU;
 input[0].ki.wScan = 0;
 input[0].ki.dwExtraInfo = 0;   
 input[0].ki.time = GetTickCount(); Sleep(5); 
 SendInput(1, input, sizeof(INPUT));
}
void AltKeyRelease()
{

    INPUT input[1] = { '\0' };       
 memset(input, 0, sizeof(input));            
 input[0].type = INPUT_KEYBOARD;   
 input[0].ki.dwFlags = KEYEVENTF_KEYUP; 
 input[0].ki.wVk = VK_MENU;
 input[0].ki.wScan = 0;
 input[0].ki.dwExtraInfo = 0;   
 input[0].ki.time = GetTickCount(); Sleep(5); 
 SendInput(1, input, sizeof(INPUT));
}

No comments:

Post a Comment