HotKey でキーリピートを無視する機能が付いたらしい

Windows SDK に含まれるインクルードファイルは,OS の新機能を知る良い情報源のひとつなわけですが,最新の*1 winuser.h に以下のような部分を発見.

WINUSERAPI
BOOL
WINAPI
RegisterHotKey(
    __in_opt HWND hWnd,
    __in int id,
    __in UINT fsModifiers,
    __in UINT vk);

WINUSERAPI
BOOL
WINAPI
UnregisterHotKey(
    __in_opt HWND hWnd,
    __in int id);

#define MOD_ALT         0x0001
#define MOD_CONTROL     0x0002
#define MOD_SHIFT       0x0004
#define MOD_WIN         0x0008
#if(WINVER >= 0x0601)
#define MOD_NOREPEAT    0x4000
#endif /* WINVER >= 0x0601 */

最後の MOD_NOREPEAT に注目.(注: Windows 7 の WINVER は 0x0601)
これはと思って,手元の Windows 7 β (7000) で Windows key + e を押しっぱなしにしてみましたが,以前のように大量に Explorer が表示されることはなく,一枚だけ表示されました.なるほど.
MSDN Library Online の方も既に更新済みのようです.以下 RegisterHotKey API の解説.

MOD_NOREPEAT
Windows 7 and later: Changes the hotkey behavior so that the keyboard auto-repeat does not yield multiple hotkey notifications.

Examples

The following example shows how to use the RegisterHotKey function with the MOD_NOREPEAT flag. In this example, the hotkey 'ALT+b' is registered for the main thread. When the hotkey is pressed, the thread will receive a WM_HOTKEY message, which will get picked up in the GetMessage call. Because this example uses MOD_ALT with the MOD_NOREPEAT value for fsModifiers, the thread will only receive another WM_HOTKEY message when the 'b' key is released and then pressed again while the 'ALT' key is being pressed down.

#include "stdafx.h"

int _cdecl _tmain (
    int argc, 
    TCHAR *argv[])
{           
    if (RegisterHotKey(
        NULL,
        1,
        MOD_ALT | MOD_NOREPEAT,
        0x42))  //0x42 is 'b'
    {
        _tprintf(_T("Hotkey 'ALT+b' registered, using MOD_NOREPEAT flag\n"));
    }
 
    MSG msg = {0};
    while (GetMessage(&msg, NULL, 0, 0) != 0)
    {
        if (msg.message == WM_HOTKEY)
        {
            _tprintf(_T("WM_HOTKEY received\n"));            
        }
    } 
 
    return 0;
}

To download the complete project, visit MSDN Code Gallery.

*1:Windows SDK for Windows 7 and .NET Framework 3.5 Service Pack 1: Beta (7000.0.4011)