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.
The registry-based solution on its own completely disables locking the system (even via the
Start
menu).Here is a method that actually provides a way to lock the computer without the Win-L chord. Locking can either be done via a shortcut on the taskbar or by pressing them in sequence followed by Enter.
First, create a batch file that can toggle system locking and trigger the lock itself; instructions for doing this are taken from a forum post:
Create reg-edit files for turning system locking on or off. This is the same as in Brent Foust's answer.
In
DisableLockWorkstation.reg
:In
EnableLockWorkstation.reg
:Run the reg-edit script for disabling the system lock.
Create a batch file to toggle the feature using the
.reg
files:Now, you can create a shortcut and pin it to the taskbar:
cmd.exe /C "<path>\lock.bat"
, where<path>
is the full path to thelock.bat
file.As mentioned above, once you've completed the above procedure, you should be able to lock the computer using Win, L, Enter in sequence (not as a chord--though see below for a solution using Ctrl-Alt-L as a chord). This is because that sequence is interpreted as follows:
lock.bat
shortcut was always the first L result if it was the only shortcut on my taskbar starting with L. (Verify this before attempting to lock your computer this way!)Below is a picture of the taskbar shortcut I made (using this icon):
EDIT: Using a chord, such as Ctrl-Alt-L
In the comments below, user lub094 suggests a way to assign the shortcut to the chord Ctrl-Alt-L (or whatever shortcut you'd like). I have not taken the time to test this because I've re-enabled the system shortcut, but I assume that it works.
Use the built-in shortcut-creation feature to assign the chord:
Place the shortcut itself in the Start Menu folder:
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:Note that you need a low-level keyboard hook. A normal keyboard hook (
WH_KEYBOARD
) won't catch hotkey events.Looks like you can't.
(http://www.autohotkey.com/docs/misc/Override.htm)
But you could try using Tweak UI. Under the Explorer tree view item, uncheck "Enabled Windows+X" hotkeys. Hoekey also might work, haven't tried it. Source.
The @FrancoisB method works for Win8 and Win7. To automate the solution:
Create a text file with the .reg suffix (DisableWinL.reg, for example)
Paste the following content and save the file:
Open that file with RegEdit (double-click should work) to execute the change.
This file can be copied to a new machine to repeat the process. And another one named something like "EnableWinL.reg" could be created that re-enables the Win+L key:
You need to set the following registry key to completely disable the Windows locking feature:
And restart the computer.
This works on Win7, Win8 and Win10