Overriding or Disabling Hotkeys

You can disable all built-in Windows hotkeys except Win+L and Win+U by making the following change to the registry (should work on all OSes, reboot is probably required):
NoWinKeys REG_DWORD 0x00000001 (1)

But read on if you want to do more than just disable them all. Note that most of the below examples are not supported on Windows Me/98/95.

Hotkeys owned by another application can be overridden or disabled simply by assigning them to an action in the script. The most common use for this feature is to change the hotkeys that are built into Windows itself. For example, if you wish Win+E (the shortcut key that launches Windows Explorer) to perform some other action, use this:

MsgBox, This hotkey is now owned by the script.

In this next example, the Win+R hotkey, which is used to open the RUN window, is completely disabled:


Similarly, to disable both Windows keys, use this:


To disable or change an application's non-global hotkey (that is, a shortcut key that only works when that application is the active window), consider the following example which disables Control+P (Print) only for Notepad, leaving the key in effect for all other types of windows:

SetTitleMatchMode, 2
IfWinActive, - Notepad, , Return
Send, ^p

In the above example, the $ prefix is needed so that the hotkey can "send itself" without activating itself (which would otherwise trigger a warning dialog about an infinite loop).

You can try out any of the above examples by copying them into a new text file such as "Override.ahk", then launching the file.