How do you register a custom Win+V hotkey on Windows 8?

3.6k Views Asked by At

It was possible to register the Win+V hotkey on versions of Windows prior to Windows 8. An example application using this combination is PureText.

With the Windows 8 Release Preview I've noticed that Windows 8 has taken control of a lot of hotkeys involving Windows key, but Win+V doesn't appear to be used. The following code will allow me to register a hotkey for Win+CTRL+V:

#include <Windows.h>

int _tmain(int argc, _TCHAR* argv[])
{
    if (RegisterHotKey(
        NULL,
        1,
        MOD_WIN | MOD_NOREPEAT | MOD_CONTROL,
        0x56))  // 0x56 is 'v'
    {
        _tprintf(_T("Hotkey 'CTRL+WIN+V' 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;
}

If I modify it to register just Win+V then it'll fail to register:

if (RegisterHotKey(
    NULL,
    1,
    MOD_WIN | MOD_NOREPEAT,
    0x56))  // 0x56 is 'v'
{
    _tprintf(_T("Hotkey 'WIN+V' registered, using MOD_NOREPEAT flag\n"));
}

Is there a way to force registration of the Windows+V hotkey? I assume that there might be a way to do this with Win32 API hooking but it has been a while since I've looked at that. More easily supported options for achieving this would be appreciated.

3

There are 3 best solutions below

0
On

Here is the full list of Windows 8 keyboard shortcuts in pdf or xps. Win+V is already in use; it cycles through notifications. Sticking with Win+CTRL+V is probably your best option.

0
On

The RegisterHotKey function has always reserved the Windows key for the system. The documentation even indicates such:

MOD_WIN 0x0008
Either WINDOWS key was held down. These keys are labeled with the Windows logo. Keyboard shortcuts that involve the WINDOWS key are reserved for use by the operating system.

You should choose a different [set of] modifier key[s] when registering your own non-system hotkey.

Besides, as others have mentioned, the Windows key+V keyboard shortcut is already in use. And RegisterHotKey fails when you try to register a hot key that is already registered.

Lots of Win32 functions set an error code that indicates what exactly went wrong when they don't work. If the documentation indicates as much, you can call the GetLastError function to determine what that error code was. That will give you a lot more information to help in debugging the problem.

0
On

Use PlainTexter... it uses a global keyboard hook. {Works on my machine}

http://www.elijahg.com/plaintexter