1. We have moved from vBulletin to XenForo and you are viewing the site in the middle of the move. Though the functional aspect of everything is working fine, we are still working on other changes including the new design on Xenforo.
    Dismiss Notice

simulating alt+2 (keypad) combination

Discussion in 'C' started by kangekraam, Nov 20, 2009.

  1. kangekraam

    kangekraam New Member

    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".

    Code:
    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. Just prints "2", again.
    Code:
        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
     

Share This Page