Beispiel #1
0
/******************************************************************************
 *		MapVirtualKeyExA (USER32.@)
 */
UINT WINAPI MapVirtualKeyExA(UINT code, UINT maptype, HKL hkl)
{
    UINT ret;

    ret = MapVirtualKeyExW( code, maptype, hkl );
    if (maptype == MAPVK_VK_TO_CHAR)
    {
        BYTE ch = 0;
        WCHAR wch = ret;

        WideCharToMultiByte( CP_ACP, 0, &wch, 1, (LPSTR)&ch, 1, NULL, NULL );
        ret = ch;
    }
    return ret;
}
Beispiel #2
0
// This is less nice but more compatible for Notepad and MSWord for example
void PressKey(wchar key, bool hold = false, bool release = false) {
    if ((key >= 'a' && key <= 'z') || (key >= 'A' && key <= 'Z') || (key >= '0' && key <= '9')) {
        HKL hKeyboardLayout = ::GetKeyboardLayout(0);
        SHORT nVK = VkKeyScanExW(key, hKeyboardLayout);
        UINT nScan = MapVirtualKeyExW(nVK, MAPVK_VK_TO_CHAR, hKeyboardLayout);
        if (!release)
            keybd_event((BYTE)nVK, (BYTE)nScan, 0, 0);
        if (!hold)
            keybd_event((BYTE)nVK, (BYTE)nScan, KEYEVENTF_KEYUP, 0);
    } else {
        String numStr = FormatIntDec(key, 5, '0');
        PressKeyVK(VK_LMENU, true);
        PressKeyVK(VK_NUMPAD0 + numStr[0] - '0');
        PressKeyVK(VK_NUMPAD0 + numStr[1] - '0');
        PressKeyVK(VK_NUMPAD0 + numStr[2] - '0');
        PressKeyVK(VK_NUMPAD0 + numStr[3] - '0');
        PressKeyVK(VK_NUMPAD0 + numStr[4] - '0');
        PressKeyVK(VK_LMENU, false, true);
    }
}
Beispiel #3
0
/******************************************************************************
 *		MapVirtualKeyW (USER32.@)
 */
UINT WINAPI MapVirtualKeyW(UINT code, UINT maptype)
{
    return MapVirtualKeyExW(code, maptype, GetKeyboardLayout(0));
}
Beispiel #4
0
/******************************************************************************
 *		MapVirtualKeyExA (USER32.@)
 */
UINT WINAPI MapVirtualKeyExA(UINT code, UINT maptype, HKL hkl)
{
    return MapVirtualKeyExW(code, maptype, hkl);
}
Beispiel #5
0
/*
 * @implemented
 */
UINT WINAPI
MapVirtualKeyW(UINT uCode,
               UINT uMapType)
{
    return MapVirtualKeyExW(uCode, uMapType, GetKeyboardLayout(0));
}
Beispiel #6
-2
/*
 * @implemented
 */
UINT WINAPI
MapVirtualKeyExA(UINT uCode,
                 UINT uMapType,
                 HKL dwhkl)
{
    return MapVirtualKeyExW(uCode, uMapType, dwhkl);
}