Is it possible to re-assign the Win+L hotkey to another executable/shortcut?
Use-case - I would like to switch off the monitor of my laptop as soon as it is locked. I know of a executable which can lock and turn off the monitor but I do not want to change the way the system is locked (by running the program explicitly or by some other shortcut). It would be best if Win+L can be assigned to this executable.
Press the Windows Key + L Press the Windows and L keys at the same time. It should lock instantly.
Windows-L Hit the Windows key and the L key on your keyboard. Keyboard shortcut for the lock!
You need to set the following registry key to completely disable the Windows locking feature:
[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\System] "DisableLockWorkstation"=dword:00000001
And restart the computer.
This works on Win7, Win8 and Win10
The Win+L is a system assigned hotkey and there's no option to disable it. This means there's no way for an application to detect it, unless you use a low-level global keyboard hook (WH_KEYBOARD_LL
). This works in XP SP3; haven't tested it in Vista though:
LRESULT CALLBACK LowLevelKeyboardProc(int code, WPARAM wparam, LPARAM lparam) { KBDLLHOOKSTRUCT& kllhs = *(KBDLLHOOKSTRUCT*)lparam; if (code == HC_ACTION) { // Test for an 'L' keypress with either Win key down. if (wparam == WM_KEYDOWN && kllhs.vkCode == 'L' && (GetAsyncKeyState(VK_LWIN) < 0 || GetAsyncKeyState(VK_RWIN) < 0)) { // Place some code here to do whatever you want. // ... // Return non-zero to halt message propagation // and prevent the Win+L hotkey from getting activated. return 1; } } return CallNextHookEx(0, code, wparam, lparam); }
Note that you need a low-level keyboard hook. A normal keyboard hook (WH_KEYBOARD
) won't catch hotkey events.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With